-
Notifications
You must be signed in to change notification settings - Fork 24
Setup local testnet for integration testing #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
77db48b
feat(testing): Implement local testing environment for indexer services
neithanmo f53c3d1
fix(testing): Organize containers and configurations into its owne co…
neithanmo 968ecdf
fix(testing): add reload script and container builder script to setup…
neithanmo adf2908
fix(testing): Remove unnecessary tests and files
neithanmo 06cfef5
fix(testing): Update justfile and add a Makefile(for future CI)
neithanmo 519e2e1
feat(testing): Add a minimal workflow for integration testing using l…
neithanmo 0afaa14
fix(service): tap-agent start script to use settings from .env variab…
neithanmo 740a947
fix(testing): Fix docker command in makefile
neithanmo cad130e
chore(testnet): Add more logs and double check for contracts to be de…
neithanmo 92170b5
fix(testing_setup): Update local network and enable missing services
neithanmo 5480a80
feat(local_network): Enable the gateway service
neithanmo 059b2f6
fix(indexer-testing): Use same auth token as gateway
neithanmo d6ebb30
fix(testing): Use reasonable values to configure RAV request in tap-a…
neithanmo 3e449a5
chore(testing): Remove old testing script
neithanmo 62bfb87
feat(testing): Add end to end testing for RAV generation
neithanmo 663c73d
fix(git): Add new items to gitignore
neithanmo 4790efb
fix(makefile): Avoid triggering errors if no container is active
neithanmo 74ce3fe
fix(ci): Enable test execution on push
neithanmo fe2af78
fix(rav_test): Increase number of receipts to ensure we hit rav gener…
neithanmo 51bbc4d
fix(ci): Disable local testnet testing for now
neithanmo 7def4a3
fix(Makefile): Update help and ensure funding script is executed befo…
neithanmo 6ae72c0
fix(testing_plan): Remove code example and improve description of tes…
neithanmo 73f00e4
chore(local_testnet): Update README and Fix down action in justfile
neithanmo 41a22f2
fix(license): Add license headers
neithanmo 7275a17
fix(ci): Ignore Dockerfile, docker compose, bash scripts and configur…
neithanmo 0015b69
fix(ci): Restore original Dockerfiles for indexer and tap-agent services
neithanmo 2c62eca
fix(ci): Ignore bash scripts in rav_e2e testing
neithanmo b11e926
fix(ci): Fix syntax error
neithanmo 0bfaa0a
chore(test): Reduce timestamp_buffer_secs window
neithanmo 2eb4d31
chore(testing): Improve test by checking for metrics after sending re…
neithanmo 3035ec9
feat(rav_test): Organize better testing code
neithanmo c1312ee
fix(gateway_service): Add health check after deploying gateway to ens…
neithanmo 6205c5f
fix(justfile): Update test command
neithanmo 6ac450c
fix(make): Remove Makefile and used Justfile instead
neithanmo 6123ed2
fix(setup): Fix setup script docker storage report and ensure we mine…
neithanmo f91ba7b
fix(docs): Update README instruction to setting up local network and …
neithanmo e74d2d3
fix(test): Ensure contracts are mined before verification
neithanmo 43fc827
fix(test): Sent only 3 receipts per batch otherwise they could be dis…
neithanmo e610328
fix(test): Remove premature block mining
neithanmo d3ea08d
chore(test): Change crate name and made it part of the workspace
neithanmo e32bb79
fix(license): Update path to exclude bash script for testing
neithanmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Test GraphTally Protocol | ||
| on: | ||
| push: | ||
| # branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Docker | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Set up Docker cache | ||
| uses: docker/setup-buildx-action@v2 | ||
| with: | ||
| install: true | ||
|
|
||
| - name: Run make setup | ||
| run: make setup | ||
|
|
||
| - name: Run tests | ||
| run: make rav_tests | ||
|
|
||
| - name: Tear down containers | ||
| if: always() | ||
| run: make down | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Developer Setup Guide | ||
|
|
||
| This guide provides the step to set up a development workflow for the indexer-service project testing. | ||
| Including how to build and deploy the required containers, and how to use hot-reload for faster dev iterations. | ||
|
|
||
| ### Note | ||
|
|
||
| The current implementation leverages local-network for the common services and uses its testing configuration. | ||
|
|
||
| ## Available Commands | ||
|
|
||
| We provide the following Make/Just commands to streamline your development workflow: | ||
|
|
||
| - `just setup` - Full setup of all services, dependencies and binary compilation | ||
| - `just reload` - Rebuild Rust binaries and restart services after code changes | ||
| - `just logs` - Watch log output from all services | ||
| - `just down` - Stop all services | ||
| - `just test-local` - Run integration tests against local services | ||
|
|
||
| ## Initial Setup | ||
|
|
||
| To get started with development: | ||
|
|
||
| 1. Clone the repository | ||
| 2. Run the full setup to initialize all services: | ||
|
|
||
| ```bash | ||
| just setup | ||
| ``` | ||
|
|
||
| This will: | ||
|
|
||
| - Clone the local-network repo if needed | ||
| - Start core infrastructure services | ||
| - Deploy contracts and required services | ||
| - Set up and start the indexer and tap-agent services | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| After the initial setup, you can use the fast development workflow: | ||
|
|
||
| 1. Make changes to the Rust code in `crates/` | ||
| 2. Run the reload command to rebuild and restart indexer and tap-agent services: | ||
|
|
||
| ```bash | ||
| just reload | ||
| ``` | ||
|
|
||
| This workflow is much faster because: | ||
|
|
||
| - It only recompiles the Rust code | ||
| - It doesn't rebuild Docker containers | ||
| - It restarts only the necessary services | ||
|
|
||
| The `reload` command will automatically show the logs after restarting, so you can see if your changes are working properly. | ||
|
|
||
| ## How It Works | ||
|
|
||
| The development workflow uses volume mounts to avoid rebuilding containers: | ||
|
|
||
| 1. A base Docker image with all dependencies is created once | ||
| 2. Your code is compiled locally on your machine | ||
| 3. The compiled binaries are mounted into the containers | ||
| 4. Services are restarted with the new binaries | ||
|
|
||
| This approach avoids the time-consuming container rebuild process while still maintaining a consistent containerized environment. | ||
|
|
||
| ## Viewing Logs | ||
|
|
||
| To monitor the services during development: | ||
|
|
||
| ```bash | ||
| just logs | ||
| ``` | ||
|
|
||
| This will show a live stream of logs from all services, which is useful for debugging. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| To run integration tests against your local environment: | ||
|
|
||
| ```bash | ||
| just local-test | ||
| ``` | ||
|
|
||
| This is currently a work in progress, and additional testing strategies are still being defined and implemented. | ||
|
|
||
| ## Stopping Services | ||
|
|
||
| When you're done working: | ||
|
|
||
| ```bash | ||
| just down | ||
| ``` | ||
|
|
||
| This will stop and remove all the containers defined in the docker-compose file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FROM debian:bookworm-slim | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| openssl ca-certificates protobuf-compiler postgresql-client curl \ | ||
| jq \ | ||
| && rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| services: | ||
| indexer-service: | ||
| image: indexer-base:latest | ||
| container_name: indexer-service | ||
| volumes: | ||
| - ../target/release/indexer-service-rs:/usr/local/bin/indexer-service-rs | ||
| - ./indexer-service/start.sh:/usr/local/bin/start.sh | ||
| - ./indexer-service/config.toml:/opt/config/config.toml | ||
| - ../local-network/contracts.json:/opt/contracts.json:ro | ||
| - ../local-network/.env:/opt/.env:ro | ||
| - ../migrations:/opt/migrations:ro | ||
| entrypoint: ["/usr/local/bin/start.sh"] | ||
| environment: | ||
| - RUST_BACKTRACE=1 | ||
| - RUST_LOG=debug | ||
| ports: | ||
| - "7601:7601" | ||
| networks: | ||
| - local-network | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:7601/"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 10 | ||
| start_period: 10s | ||
|
|
||
| tap-agent: | ||
| image: indexer-base:latest # Pre-built base image with dependencies | ||
| container_name: tap-agent | ||
| depends_on: | ||
| indexer-service: | ||
| condition: service_healthy | ||
| volumes: | ||
| - ../target/release/indexer-tap-agent:/usr/local/bin/indexer-tap-agent | ||
| - ./tap-agent/start.sh:/usr/local/bin/start.sh | ||
| - ./tap-agent:/opt/config:ro | ||
| - ./local-network/.env:/opt/.env:ro | ||
| - ./local-network/contracts.json:/opt/contracts.json:ro | ||
| - ../migrations:/opt/migrations:ro | ||
| entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"] | ||
| environment: | ||
| - RUST_BACKTRACE=1 | ||
| - RUST_LOG=debug | ||
| ports: | ||
| # to expose the metrics port | ||
| - "7300:7300" | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:7300/metrics"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 10 | ||
| start_period: 10s | ||
|
|
||
| networks: | ||
| local-network: | ||
| external: true | ||
| name: local-network_default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| services: | ||
| indexer-service: | ||
| build: | ||
| context: .. # Go up one level to the root directory | ||
| dockerfile: ./contrib/indexer-service/Dockerfile | ||
| container_name: indexer-service | ||
| volumes: | ||
| - ./indexer-service:/opt/config:ro # From contrib dir to indexer-service dir | ||
| - ./local-network/contracts.json:/opt/contracts.json:ro | ||
| - ./local-network/.env:/opt/.env:ro | ||
| - ../migrations:/opt/migrations:ro | ||
| entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"] | ||
| environment: | ||
| - RUST_BACKTRACE=1 | ||
| - RUST_LOG=debug | ||
| ports: | ||
| - "7601:7601" | ||
| networks: | ||
| - local-network | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:7601/"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 10 | ||
| start_period: 10s | ||
|
|
||
| tap-agent: | ||
| build: | ||
| context: .. | ||
| dockerfile: ./contrib/tap-agent/Dockerfile | ||
| container_name: tap-agent | ||
| depends_on: | ||
| indexer-service: | ||
| condition: service_healthy | ||
| volumes: | ||
| - ./tap-agent:/opt/config:ro # From contrib dir to tap-agent dir | ||
| - ./local-network/.env:/opt/.env:ro | ||
| - ./local-network/contracts.json:/opt/contracts.json:ro | ||
| - ../migrations:/opt/migrations:ro | ||
| entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"] | ||
| environment: | ||
| - RUST_BACKTRACE=1 | ||
| - RUST_LOG=debug | ||
| ports: | ||
| # to expose the metrics port | ||
| - "7300:7300" | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:7300/metrics"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 10 | ||
| start_period: 10s | ||
|
|
||
| networks: | ||
| local-network: | ||
| external: true | ||
| name: local-network_default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| FROM rust:1.81-bookworm as build | ||
| WORKDIR /root | ||
| # Copy from the root project directory (two levels up) | ||
| COPY ../../ . | ||
| # Force SQLx to use the offline mode to statically check the database queries against | ||
| # the prepared files in the `.sqlx` directory. | ||
| # | ||
| ENV SQLX_OFFLINE=true | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| protobuf-compiler && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN cargo build --release --bin indexer-service-rs | ||
|
|
||
| ######################################################################################## | ||
|
|
||
| FROM debian:bookworm-slim | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| openssl ca-certificates protobuf-compiler postgresql-client curl \ | ||
| jq \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=build /root/target/release/indexer-service-rs /usr/local/bin/indexer-service-rs | ||
|
|
||
| # Copy our start script into the image | ||
| COPY contrib/indexer-service/start.sh /usr/local/bin/start.sh | ||
| COPY contrib/indexer-service/config.toml /opt/config/config.toml | ||
|
|
||
| RUN chmod +x /usr/local/bin/start.sh | ||
|
|
||
| ENTRYPOINT [ "/usr/local/bin/start.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| [indexer] | ||
| indexer_address = "INDEXER_ADDRESS_PLACEHOLDER" | ||
| operator_mnemonic = "INDEXER_MNEMONIC_PLACEHOLDER" | ||
|
|
||
| [database] | ||
| postgres_url = "postgres://postgres@postgres:POSTGRES_PORT_PLACEHOLDER/indexer_components_1" | ||
|
|
||
| [graph_node] | ||
| query_url = "http://graph-node:8000" | ||
| status_url = "http://graph-node:8030/graphql" | ||
|
|
||
| [subgraphs.network] | ||
| query_url = "http://graph-node:8000/subgraphs/name/graph-network" | ||
| deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER" | ||
|
|
||
| [subgraphs.escrow] | ||
| query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap" | ||
| deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER" | ||
|
|
||
| [blockchain] | ||
| chain_id = 1337 | ||
| receipts_verifier_address = "VERIFIER_ADDRESS_PLACEHOLDER" | ||
|
|
||
| [service] | ||
| host_and_port = "0.0.0.0:7601" | ||
| free_query_auth_token = "freestuff" | ||
|
|
||
| [service.tap] | ||
| max_receipt_value_grt = "0.001" | ||
|
|
||
| [tap] | ||
| max_amount_willing_to_lose_grt = 1000 | ||
|
|
||
| [tap.rav_request] | ||
| # Set a lower timestamp buffer threshold | ||
| timestamp_buffer_secs = 30 | ||
| # The trigger value divisor is used to calculate the trigger value for the RAV request. | ||
| # using the formula: | ||
| # trigger_value = max_amount_willing_to_lose_grt / trigger_value_divisor | ||
| # where the default value for max_amount_willing_to_lose_grt is 1000 | ||
| # the idea to set this for trigger_value to be 0.002 | ||
| # requiring the sender to send at least 20 receipts of 0.0001 grt | ||
| trigger_value_divisor = 500_000 | ||
|
|
||
| [tap.sender_aggregator_endpoints] | ||
| "ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.