Skip to content

Commit ab02703

Browse files
committed
docs(integration-testing): update integration-testing instructions
1 parent f19636f commit ab02703

File tree

1 file changed

+111
-2
lines changed

1 file changed

+111
-2
lines changed

integration-tests/INTEGRATION_TESTING_INSTRUCTIONS.md

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,20 @@ just down
245245
- RAV generation depends on receipt volume and timing
246246
- Check service health with `docker ps`
247247

248+
5. **TAP Agent panic on receipt processing****FULLY RESOLVED**:
249+
- **Symptom**: Receipts are stored but no unaggregated fees accumulate, system crashes
250+
- **Root Cause**: Collection ID parsing errors with `.expect()` causing panics in notification handler + database padding from `character(64)` fields
251+
- **Fix Applied**:
252+
- Added error handling to prevent panics on malformed collection IDs
253+
- Added `.trim()` to handle padded collection IDs from fixed-length database fields
254+
- Added debug logging for notification processing
255+
- **Status**: ✅ **COMPLETELY FIXED** - system processes receipts and accumulates fees correctly
256+
- **Verification**:
257+
- ✅ Logs show successful notification processing: `Successfully handled notification`
258+
- ✅ Metrics show accumulated fees: `tap_unaggregated_fees_grt_total` > 0
259+
- ✅ Load tests process 50+ receipts without errors
260+
- ✅ No panics or crashes during continuous operation
261+
248262
### Debug Commands
249263

250264
**Check contract deployment**:
@@ -266,6 +280,48 @@ docker exec chain cast block-number --rpc-url http://localhost:8545
266280
```bash
267281
# Check for TAP receipts
268282
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*) FROM scalar_tap_receipts;"
283+
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*) FROM tap_horizon_receipts;"
284+
```
285+
286+
**Service restart after issues**:
287+
288+
If you encounter notification processing issues or panics, restart the services:
289+
290+
```bash
291+
# Restart both indexer-service and tap-agent
292+
cd contrib && docker compose -f docker-compose.dev.yml restart indexer-service tap-agent
293+
294+
# Or rebuild and restart (if code changes were made)
295+
just reload
296+
```
297+
298+
**Verify notification listeners**:
299+
300+
```bash
301+
# Check that both notification channels are being listened to
302+
docker logs tap-agent 2>&1 | grep "LISTEN"
303+
# Should show:
304+
# LISTEN "scalar_tap_receipt_notification" (V1/Legacy)
305+
# LISTEN "tap_horizon_receipt_notification" (V2/Horizon)
306+
```
307+
308+
**Check receipt processing is working**:
309+
310+
```bash
311+
# Verify receipts are being processed into unaggregated fees (should show non-zero values)
312+
curl -s http://localhost:7300/metrics | grep -E "tap_unaggregated_fees|tap_ravs_created"
313+
314+
# Check database for stored receipts
315+
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*), SUM(value) FROM tap_horizon_receipts;"
316+
317+
# Verify successful notification processing (should show "Successfully handled notification")
318+
docker logs tap-agent --tail 20 | grep -E "(Successfully handled notification|Received notification)"
319+
320+
# Verify no recent panics in logs (should report "No recent panics")
321+
docker logs tap-agent --since="5m" 2>&1 | grep -i panic || echo "No recent panics - system healthy"
322+
323+
# Quick load test to verify processing (should show 50 successful receipts)
324+
cd integration-tests && cargo run -- load --num-receipts 50
269325
```
270326

271327
## Test Success Criteria
@@ -279,8 +335,10 @@ docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*
279335
### V2 Tests
280336

281337
- ✅ V2 receipts are accepted without "402 Payment Required" errors
282-
- ✅ System runs in Horizon hybrid migration mode
338+
- ✅ System runs in Horizon hybrid migration mode
283339
- ✅ Collection IDs are properly handled
340+
- ✅ Unaggregated fees accumulate correctly (receipts are processed)
341+
- ⚠️ RAV generation may require additional configuration (trigger thresholds, timing)
284342

285343
### Load Tests
286344

@@ -304,4 +362,55 @@ After successful testing, consider:
304362
2. **Explore refactoring opportunities**: Review `INTEGRATION_TESTING_IMPROVEMENTS.md`
305363
3. **Contribute improvements**: Follow the refactoring roadmap for better testing infrastructure
306364

307-
This testing infrastructure provides a solid foundation for developing and testing both V1 and V2 TAP functionality in indexer-rs.
365+
This testing infrastructure provides a solid foundation for developing and testing both V1 and V2 TAP functionality in indexer-rs.
366+
367+
## TAP Receipt Processing Investigation Guide
368+
369+
If you encounter issues where receipts are stored but not processed (unaggregated fees remain 0), follow this systematic debugging approach:
370+
371+
### Step 1: Check System Health
372+
```bash
373+
# Look for panics that crash the notification system
374+
docker logs tap-agent 2>&1 | grep -E "(panic|PANIC)" | tail -5
375+
376+
# Verify receipt watchers are running
377+
docker logs tap-agent | grep "receipts watcher started" | tail -2
378+
```
379+
380+
### Step 2: Test Notification System
381+
```bash
382+
# Send test notification to verify the system receives them
383+
docker exec postgres psql -U postgres -d indexer_components_1 -c "NOTIFY tap_horizon_receipt_notification, '{\"id\": 1, \"collection_id\": \"5819cd0eb33a614e8426cf3bceaced9d47e178c8\", \"signer_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\", \"timestamp_ns\": 1000000000, \"value\": 100}';"
384+
385+
# Check if notification was processed (should see logs)
386+
docker logs tap-agent --tail 20
387+
```
388+
389+
### Step 3: Verify Database Triggers
390+
```bash
391+
# Check trigger function exists
392+
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT pg_get_functiondef(oid) FROM pg_proc WHERE proname = 'tap_horizon_receipt_notify';"
393+
394+
# Verify trigger is attached
395+
docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT tgname, relname FROM pg_trigger JOIN pg_class ON tgrelid = pg_class.oid WHERE tgname LIKE '%notify%';"
396+
```
397+
398+
### Step 4: Clear Problematic Data (if needed)
399+
```bash
400+
# If malformed data causes issues, clear and restart
401+
docker exec postgres psql -U postgres -d indexer_components_1 -c "TRUNCATE tap_horizon_receipts CASCADE;"
402+
docker exec postgres psql -U postgres -d indexer_components_1 -c "TRUNCATE scalar_tap_receipts CASCADE;"
403+
just reload
404+
```
405+
406+
### Expected Behavior
407+
- ✅ Receipt watchers start without panics
408+
- ✅ Test notifications are received and logged
409+
- ✅ Database triggers send properly formatted notifications
410+
- ✅ Receipts are processed into unaggregated fees
411+
- ✅ System runs continuously without crashes
412+
413+
### Key Files for TAP Processing
414+
- `crates/tap-agent/src/agent/sender_accounts_manager.rs`: Notification handling
415+
- Database triggers: `tap_horizon_receipt_notify()` and `scalar_tap_receipt_notify()`
416+
- Metrics endpoint: `http://localhost:7300/metrics`

0 commit comments

Comments
 (0)