Skip to content

Conversation

@neithanmo
Copy link
Collaborator

@neithanmo neithanmo commented Apr 3, 2025

This PR introduces a local-testnet and an integration test to validate that the receipt aggregation and RAV generation functionality works correctly in a real-world environment.

Key Changes

  • Added a TAP RAV generation test that verifies receipts are properly aggregated into RAVs(this is a custom rust binary that is part of the workspace)
  • Implemented metrics monitoring to detect successful RAV generation
  • Added proper indexer-service and tap-agent configurations to make testing times shorter
  • Implement testing checks that compares pre-test and post-test metrics

Testing Details

The tests deploy and interact with a complete local testnet environment using Docker containers, including:

  • Indexer service
  • TAP agent
  • TAP aggregator
  • Blockchain node with deployed contracts
  • tap-contracts deployments
  • Database
  • block oracles
  • Gateway
  • indexer-agent(not use directly)

The integration test:

  1. Funds the escrow contract with sufficient GRT(using a bash script)
  2. Sends multiple receipts in batches
  3. Waits for the timestamp buffer period to ensure receipts age appropriately
  4. Verifies that RAVs are successfully created via metrics examination

Missing Checks

  • The current test does not check for RAV claims/redemption from the indexer-agent
  • Test does not check for the RAV amounts to be equal to a pre-computed value

How to setup and run:

In order to try this locally:

  1. Check if your local setup is already running a posgress database, if that is the case stop that service
  2. run just setup to build and run containers
  3. If previous step was completed successfully, then, run the test: just test-local

Set up a comprehensive Docker-based testing environment that simulates a
production-like setup for indexer services. This includes:

- Integration with local-network components (chain, IPFS, graph-node, contracts)
- Custom services configuration with proper database migrations
- Test scripts to validate service functionality(WIP)
- Fix for database schema creation to support cost models and deny lists
- Automated service startup with correct dependency ordering(WIP)

This environment allows testing our services against real subgraphs and
contracts, providing better validation than isolated unit tests. The setup
creates a three-tier architecture that mimics production deployment.

Tests can now validate payment receipt processing and query routing in a
realistic scenario.
…le and remove logging from indexer start script
@coveralls
Copy link

coveralls commented Apr 3, 2025

Pull Request Test Coverage Report for Build 14310527874

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 294 (0.0%) changed or added relevant lines in 4 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.9%) to 74.244%

Changes Missing Coverage Covered Lines Changed/Added Lines %
integration-tests/src/main.rs 0 4 0.0%
integration-tests/src/receipt.rs 0 26 0.0%
integration-tests/src/metrics.rs 0 87 0.0%
integration-tests/src/rav_tests.rs 0 177 0.0%
Files with Coverage Reduction New Missed Lines %
crates/tap-agent/src/agent/sender_account.rs 9 77.53%
Totals Coverage Status
Change from base Build 14193652489: -1.9%
Covered Lines: 8858
Relevant Lines: 11931

💛 - Coveralls

@neithanmo neithanmo marked this pull request as draft April 3, 2025 19:07
@neithanmo neithanmo force-pushed the feat/integration_test branch from 53a66d3 to 0015b69 Compare April 3, 2025 19:25
@neithanmo
Copy link
Collaborator Author

neithanmo commented Apr 4, 2025

I just tried running this with just setup in one terminal then just test-local in another. I got this far:

Error: contract 0x0355b7b8cb128fa5692729ab3aaa199c1753f726 does not have any code
error: Recipe `test-local` failed on line 73 with exit code 1

What's happening, I think, is that there's a subtle timing gap between when the contract deployment container finishes submitting transactions and when those contracts are actually mined and confirmed on the local network.
that did not happen on my target, so it could be a matter of timing, performance.
This could be fixed by mining some blocks between graph-contract/tap-contracts deployment and its verification in the setup script. I will add that

@suchapalaver
Copy link
Collaborator

I just tried running this with just setup in one terminal then just test-local in another. I got this far:

Error: contract 0x0355b7b8cb128fa5692729ab3aaa199c1753f726 does not have any code
error: Recipe `test-local` failed on line 73 with exit code 1

What's happening, I think, is that there's a subtle timing gap between when the contract deployment container finishes submitting transactions and when those contracts are actually mined and confirmed on the local network. that did not happen on my target, so it could be a matter of timing, performance. This could be fixed by mining some blocks between graph-contract/tap-contracts deployment and its verification in the setup script. I will add that

I deleted my comment because I jumped the gun running the local-test directive, not everything had built yet. Apologies for any confusion!

@suchapalaver
Copy link
Collaborator

I just tried running this with just setup in one terminal then just test-local in another. I got this far:

Error: contract 0x0355b7b8cb128fa5692729ab3aaa199c1753f726 does not have any code
error: Recipe `test-local` failed on line 73 with exit code 1

What's happening, I think, is that there's a subtle timing gap between when the contract deployment container finishes submitting transactions and when those contracts are actually mined and confirmed on the local network. that did not happen on my target, so it could be a matter of timing, performance. This could be fixed by mining some blocks between graph-contract/tap-contracts deployment and its verification in the setup script. I will add that

I deleted my comment because I jumped the gun running the local-test directive, not everything had built yet. Apologies for any confusion!

Ah yeah I ran into Waiting for gateway service... forever.

@neithanmo
Copy link
Collaborator Author

Ah yeah I ran into Waiting for gateway service... forever.

That happened to me as well, but it got better after mining some blocks before the gateway check,
the timeout there is 5 minutes.

@suchapalaver
Copy link
Collaborator

Ah yeah I ran into Waiting for gateway service... forever.

That happened to me as well, but it got better after mining some blocks before the gateway check, the timeout there is 5 minutes.

Your fix worked

@suchapalaver
Copy link
Collaborator

suchapalaver commented Apr 4, 2025

These values aren't changing in my output: RAVs created: 0, Unaggregated fees: 0 even at 41/100. Is that to be expected?

This is running just local-test.

Update:

=== Summary ===
Total receipts sent successfully: 140
Total value sent: 0.14 GRT
❌ TEST FAILED: No RAV generation detected
Error: Failed to detect RAV generation

@suchapalaver
Copy link
Collaborator

These values aren't changing in my output: RAVs created: 0, Unaggregated fees: 0 even at 41/100. Is that to be expected?

This is running just local-test.

Update:


=== Summary ===

Total receipts sent successfully: 140

Total value sent: 0.14 GRT

❌ TEST FAILED: No RAV generation detected

Error: Failed to detect RAV generation

Confirming this is fixed for me now 👍

suchapalaver
suchapalaver previously approved these changes Apr 7, 2025
Copy link
Collaborator

@suchapalaver suchapalaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing to have this infrastructure in place, what a great start!

I was having an issue with a very old version of protoc in apt on my new laptop and now that's fixed I can confirm this is working as described and as expected! Nice work!

Copy link
Collaborator

@TypeLevelConsoli TypeLevelConsoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so valuable, thanks!

@neithanmo
Copy link
Collaborator Author

Glad to hear
I am changing the name to integration-test/ and making it part of the workspace as well
This ensures that its compilation is also verified by CI.

@neithanmo neithanmo dismissed stale reviews from TypeLevelConsoli and suchapalaver via d3ea08d April 7, 2025 13:23
@neithanmo neithanmo enabled auto-merge (squash) April 7, 2025 14:01
@neithanmo neithanmo merged commit 8090240 into main Apr 7, 2025
10 checks passed
@neithanmo neithanmo deleted the feat/integration_test branch April 7, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants