Skip to content

Commit 3c6a537

Browse files
committed
docs(integration-testing): update integration-testing instructions
Signed-off-by: Joseph Livesey <[email protected]>
1 parent 92394ce commit 3c6a537

File tree

1 file changed

+116
-1
lines changed

1 file changed

+116
-1
lines changed

integration-tests/INTEGRATION_TESTING_INSTRUCTIONS.md

Lines changed: 116 additions & 1 deletion
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
@@ -281,6 +337,8 @@ docker exec postgres psql -U postgres -d indexer_components_1 -c "SELECT COUNT(*
281337
- ✅ V2 receipts are accepted without "402 Payment Required" errors
282338
- ✅ 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,61 @@ 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+
373+
```bash
374+
# Look for panics that crash the notification system
375+
docker logs tap-agent 2>&1 | grep -E "(panic|PANIC)" | tail -5
376+
377+
# Verify receipt watchers are running
378+
docker logs tap-agent | grep "receipts watcher started" | tail -2
379+
```
380+
381+
### Step 2: Test Notification System
382+
383+
```bash
384+
# Send test notification to verify the system receives them
385+
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}';"
386+
387+
# Check if notification was processed (should see logs)
388+
docker logs tap-agent --tail 20
389+
```
390+
391+
### Step 3: Verify Database Triggers
392+
393+
```bash
394+
# Check trigger function exists
395+
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';"
396+
397+
# Verify trigger is attached
398+
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%';"
399+
```
400+
401+
### Step 4: Clear Problematic Data (if needed)
402+
403+
```bash
404+
# If malformed data causes issues, clear and restart
405+
docker exec postgres psql -U postgres -d indexer_components_1 -c "TRUNCATE tap_horizon_receipts CASCADE;"
406+
docker exec postgres psql -U postgres -d indexer_components_1 -c "TRUNCATE scalar_tap_receipts CASCADE;"
407+
just reload
408+
```
409+
410+
### Expected Behavior
411+
412+
- ✅ Receipt watchers start without panics
413+
- ✅ Test notifications are received and logged
414+
- ✅ Database triggers send properly formatted notifications
415+
- ✅ Receipts are processed into unaggregated fees
416+
- ✅ System runs continuously without crashes
417+
418+
### Key Files for TAP Processing
419+
420+
- `crates/tap-agent/src/agent/sender_accounts_manager.rs`: Notification handling
421+
- Database triggers: `tap_horizon_receipt_notify()` and `scalar_tap_receipt_notify()`
422+
- Metrics endpoint: <http://localhost:7300/metrics>

0 commit comments

Comments
 (0)