Skip to content

Commit 6bd2b10

Browse files
authored
docs(integration-testing): add clear integration-testing instructions (#779)
1 parent 1f3ed73 commit 6bd2b10

File tree

1 file changed

+307
-0
lines changed

1 file changed

+307
-0
lines changed
Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# Integration Testing Instructions from Scratch
2+
3+
This document provides step-by-step instructions for setting up and running integration tests for indexer-rs from a fresh repository checkout.
4+
5+
## Prerequisites
6+
7+
Before starting, ensure you have the following tools installed:
8+
9+
- **Docker**: `docker --version` (tested with 28.3.2)
10+
- **Docker Compose**: `docker compose version` (tested with v2.38.2)
11+
- **Rust/Cargo**: `cargo --version` (tested with 1.88.0)
12+
- **Just**: `just --version` (tested with 1.40.0)
13+
14+
## Step 1: Initial Setup
15+
16+
1. **Navigate to repository root**:
17+
18+
```bash
19+
cd /path/to/indexer-rs
20+
```
21+
22+
2. **Verify git status**:
23+
24+
```bash
25+
git status
26+
```
27+
28+
Expected: Clean working directory on main branch.
29+
30+
## Step 2: Clean Environment
31+
32+
**Clean any existing containers**:
33+
34+
```bash
35+
just down
36+
```
37+
38+
This removes all containers and networks from previous test runs.
39+
40+
## Step 3: Full Test Network Setup
41+
42+
**Start the complete test environment**:
43+
44+
```bash
45+
just setup
46+
```
47+
48+
This command:
49+
50+
- Clones the local-network repository (branch: `suchapalaver/test/horizon`)
51+
- Starts blockchain, IPFS, PostgreSQL, and Graph Node
52+
- Deploys Graph Protocol contracts (both Legacy and Horizon)
53+
- Deploys TAP contracts
54+
- Builds and starts indexer-service and tap-agent
55+
- Deploys network subgraph with TAP v2 support
56+
- Starts supporting services (gateway, TAP aggregator, etc.)
57+
58+
**Expected output**: All services should start successfully without errors.
59+
60+
## Step 4: Verify Services Are Running
61+
62+
**Check that all critical services are healthy**:
63+
64+
```bash
65+
docker ps --format "table {{.Names}}\t{{.Status}}" | grep -E "(indexer-service|tap-agent|gateway|graph-node|chain)"
66+
```
67+
68+
Expected output:
69+
70+
```
71+
indexer-service Up X minutes (healthy)
72+
tap-agent Up X minutes (healthy)
73+
gateway Up X minutes
74+
graph-node Up X minutes (healthy)
75+
chain Up X minutes (healthy)
76+
```
77+
78+
## Step 5: Fund Escrow Accounts
79+
80+
**Fund both V1 and V2 escrow accounts**:
81+
82+
```bash
83+
cd integration-tests && ./fund_escrow.sh
84+
```
85+
86+
**Expected output**:
87+
88+
- V1 escrow successfully funded with 10 GRT
89+
- V2 escrow successfully funded with 10 GRT
90+
- Both transactions should show success confirmations
91+
92+
## Step 6: Verify Horizon Detection
93+
94+
**Check if indexer-service detects Horizon contracts**:
95+
96+
```bash
97+
docker logs indexer-service 2>&1 | grep -i horizon | tail -3
98+
```
99+
100+
**Expected output**:
101+
102+
```
103+
Horizon contracts detected in network subgraph - enabling hybrid migration mode
104+
Horizon contracts detected - using Horizon migration mode: V2 receipts only, but processing existing V1 receipts
105+
```
106+
107+
## Step 7: Run V1 Integration Tests
108+
109+
**Test Legacy TAP (V1) functionality**:
110+
111+
```bash
112+
just test-local
113+
```
114+
115+
**Expected behavior**:
116+
117+
- Funds V1 escrow accounts
118+
- Sends multiple batches of V1 receipts
119+
- Waits for timestamp buffer period
120+
- Sends trigger receipts until RAV generation is detected
121+
- **Success criteria**: Either RAVs created increases OR unaggregated fees decrease significantly
122+
123+
## Step 8: Run V2 Integration Tests
124+
125+
**Test Horizon TAP (V2) functionality**:
126+
127+
```bash
128+
just test-local-v2
129+
```
130+
131+
**Expected behavior**:
132+
133+
- Funds both V1 and V2 escrow accounts
134+
- Sends V2 receipts with collection IDs
135+
- Monitors metrics for RAV generation
136+
- **Success criteria**: V2 receipts are accepted (no "402 Payment Required" errors)
137+
138+
## Step 9: Run Load Tests
139+
140+
**Test system performance with high receipt volume**:
141+
142+
```bash
143+
just load-test-v2 1000
144+
```
145+
146+
This sends 1000 V2 receipts to test system performance.
147+
148+
## Step 10: Observe and Debug
149+
150+
### Check Network Subgraph
151+
152+
**Verify PaymentsEscrow accounts are indexed**:
153+
154+
```bash
155+
curl -s -X POST http://localhost:8000/subgraphs/name/graph-network \
156+
-H "Content-Type: application/json" \
157+
-d '{"query": "{ paymentsEscrowAccounts(first: 5) { id payer receiver balance } }"}' | jq
158+
```
159+
160+
**Expected output**:
161+
162+
```json
163+
{
164+
"data": {
165+
"paymentsEscrowAccounts": [
166+
{
167+
"id": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266f39fd6e51aad88f6f4ce6ab8827279cfffb92266f4ef6650e48d099a4972ea5b414dab86e1998bd3",
168+
"payer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
169+
"receiver": "0xf4EF6650E48d099a4972ea5B414daB86e1998Bd3",
170+
"balance": "10000000000000000000"
171+
}
172+
]
173+
}
174+
}
175+
```
176+
177+
### Check Service Logs
178+
179+
**Monitor indexer-service logs**:
180+
181+
```bash
182+
docker logs indexer-service -f
183+
```
184+
185+
**Monitor tap-agent logs**:
186+
187+
```bash
188+
docker logs tap-agent -f
189+
```
190+
191+
### Check Metrics
192+
193+
**Check TAP agent metrics**:
194+
195+
```bash
196+
curl -s http://localhost:7300/metrics | grep -E "(tap_ravs_created|tap_unaggregated_fees)"
197+
```
198+
199+
## Step 11: Development Workflow
200+
201+
### Hot Reloading
202+
203+
**Rebuild and restart services after code changes**:
204+
205+
```bash
206+
just reload
207+
```
208+
209+
### View All Service Logs
210+
211+
**Monitor all service logs**:
212+
213+
```bash
214+
just logs
215+
```
216+
217+
### Stop All Services
218+
219+
**Clean shutdown**:
220+
221+
```bash
222+
just down
223+
```
224+
225+
## Troubleshooting
226+
227+
### Common Issues
228+
229+
1. **"402 Payment Required" errors**:
230+
- Verify escrow accounts are funded
231+
- Check that Horizon detection is working
232+
- Ensure network subgraph has PaymentsEscrow accounts
233+
234+
2. **Service startup failures**:
235+
- Run `just down` to clean state
236+
- Check Docker daemon is running
237+
- Verify port availability (7300, 7601, 7700, 8000, 8545)
238+
239+
3. **Network subgraph issues**:
240+
- Check graph-node logs: `docker logs graph-node`
241+
- Verify contracts are deployed: `docker logs graph-contracts`
242+
243+
4. **Test timeouts**:
244+
- Services may take time to start
245+
- RAV generation depends on receipt volume and timing
246+
- Check service health with `docker ps`
247+
248+
### Debug Commands
249+
250+
**Check contract deployment**:
251+
252+
```bash
253+
# Check if contracts have code
254+
docker exec chain cast code 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --rpc-url http://localhost:8545 | wc -c
255+
```
256+
257+
**Check blockchain state**:
258+
259+
```bash
260+
# Get current block number
261+
docker exec chain cast block-number --rpc-url http://localhost:8545
262+
```
263+
264+
**Check database state**:
265+
266+
```bash
267+
# Check for TAP receipts
268+
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*) FROM scalar_tap_receipts;"
269+
```
270+
271+
## Test Success Criteria
272+
273+
### V1 Tests
274+
275+
- ✅ Receipts are accepted without errors
276+
- ✅ RAVs are generated (metrics show increase)
277+
- ✅ Unaggregated fees decrease after RAV generation
278+
279+
### V2 Tests
280+
281+
- ✅ V2 receipts are accepted without "402 Payment Required" errors
282+
- ✅ System runs in Horizon hybrid migration mode
283+
- ✅ Collection IDs are properly handled
284+
285+
### Load Tests
286+
287+
- ✅ System handles high receipt volume without errors
288+
- ✅ Memory usage remains stable
289+
- ✅ No significant performance degradation
290+
291+
## Key Configuration Files
292+
293+
- `contrib/indexer-service/config.toml`: Indexer service configuration
294+
- `contrib/tap-agent/config.toml`: TAP agent configuration
295+
- `contrib/local-network/.env`: Environment variables and addresses
296+
- `contrib/local-network/horizon.json`: Horizon contract addresses
297+
- `contrib/local-network/tap-contracts.json`: TAP contract addresses
298+
299+
## Next Steps
300+
301+
After successful testing, consider:
302+
303+
1. **Run comprehensive test suite**: `just ci` (includes format, lint, test, sqlx-prepare)
304+
2. **Explore refactoring opportunities**: Review `INTEGRATION_TESTING_IMPROVEMENTS.md`
305+
3. **Contribute improvements**: Follow the refactoring roadmap for better testing infrastructure
306+
307+
This testing infrastructure provides a solid foundation for developing and testing both V1 and V2 TAP functionality in indexer-rs.

0 commit comments

Comments
 (0)