Testing & Verification
Testing & Verification Guide
This guide details the steps and prerequisites required to run the Avalanche Matchmaking Protocol (AMP) test suites. By running these tests, developers can verify that their local configuration is correct and that the core matchmaking, telemetry, relay, and smart contract systems are fully ready to support active players.
Prerequisites
Before running the tests, ensure you have the following system dependencies installed:
- Rust Toolchain: Rust 1.87+ (edition 2024). Install via rustup.rs.
- Cap'n Proto Compiler: Used for generating RPC serialization code.
- Debian/Ubuntu:
sudo apt install capnproto - macOS:
brew install capnp
- Debian/Ubuntu:
- Foundry: Anvil and Forge are required for running smart contract unit tests and executing the E2E integration test local blockchain environment. Install via:
curl -L https://foundry.paradigm.xyz | bash foundryup - Go: Required for testing the Go SDK. Install version 1.22+.
- Python 3.9+: Required for testing the Python SDK (
pip install -e ".[dev]"inamp-sdk/python). - Node.js 18+: Required for testing the JavaScript SDK (
npm install && npm testinamp-sdk/js). - .NET SDK 8.0+: Required for building the C# SDK (
dotnet buildinamp-sdk/csharp/AmpSdk).
Testing Commands
AMP provides unit, SDK, and end-to-end integration tests to isolate and verify components.
1. Smart Contract Tests (Solidity)
These tests verify contract rules (reentrancy, game registrations, match creation, stakes, disputes, and withdrawals).
- Command:
cd contracts forge test -vvv - Coverage: Runs 32 automated tests verifying the
AMPRegistryandAMPSettlementcontracts on a simulated EVM runtime.
2. Rust Workspace Unit Tests
These tests cover matchmaking rule evaluation, Glicko-2 MMR calculations, persistent state storage operations, and the cross-language EIP-712 digest known-answer test.
- Command:
cargo test --workspace - Coverage: 42 tests in
AMP-Server(matchmaking, Glicko-2, auth incl. negative-path lifecycle tests, signature verification, rate-limiter, cross-language digest KAT, and a skill-pairingproptest), 14 inamp-relayer(gas, custodial derivation KAT, nonce-concurrency, constant-time API key), 5 inamp-sdk(Rust), 1 latency-gate test inamp-benches, plus a full-stackamp-integration-testsbinary (happy path + duplicate-submit idempotency). Counts grow over time — runcargo test --workspacefor the current number.
3. Go SDK Tests
These tests verify that game server integrations using the Go SDK compile and execute correctly, including the Glicko-2 NaN/Inf guard.
- Command:
(Or run
make test-sdk-gocd amp-sdk/go && go test ./...) - Coverage: Verifies the Go player session client, Glicko-2 solver with NaN-guard, and Cap'n Proto RPC structures.
4. Python SDK Tests
These tests verify the EIP-712 digest, address derivation, expiry checks, and constructor validation.
- Command:
cd amp-sdk/python && pytest - Coverage: 8 tests covering the cross-language digest KAT, signing helpers, host:port parsing, and the explicit-signer requirement.
5. JavaScript SDK Tests
These tests verify the EIP-712 digest matches the cross-language KAT (Rust/C#/Python produce the same bytes).
- Command:
cd amp-sdk/js && npm install && npm test - Coverage: 3 tests; 98% line coverage on the digest module.
6. End-to-End Integration Tests
This is the ultimate verification suite that replicates a live production environment on a local Avalanche Fuji testnet fork.
- Command:
make test-integration - Orchestration: The integration runner automatically performs the following steps:
- Starts a local
anvilinstance on a random free port configured with Chain ID43113(Fuji). - Deploys the
AMPRegistryandAMPSettlementcontracts using Forge scripts. - Starts the
amp-telemetryreceiver, theamp-relayerbridge, and theAMP-Serververifier. - Registers a game on-chain and configures verifier addresses.
- Simulates player clients authenticating via ECDSA challenges, joining queues, and matching.
- Submits game results, triggers relayer txs, checks payouts and fees on-chain, and verifies Glicko-2 ratings are successfully written to the Sled DB.
- Starts a local
Verifying System Readiness
To run all tests (Rust tests, Forge contract tests, and SDK tests) sequentially, run the following root command:
# Setup environment and dependencies
make setup
# Run all test suites
make test
# Run the E2E integration test
make test-integration
If the console outputs ALL INTEGRATION TESTS PASSED SUCCESSFULLY!, the matchmaking stack is fully operational, secure, and ready to host live multiplayer matches.