-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Overview
The lnpixels-listener.js integrates with the LNPixels service to listen for pixel purchase events and trigger agent responses. With 41.95% coverage, much of the LNPixels integration is untested.
Current Coverage
- Statements: 41.95%
- Branches: 15.62%
- Functions: 33.33%
- Lines: 41.95%
- Target: 100% coverage
Uncovered Areas
Major untested sections:
- WebSocket connection management
- Event listening and parsing
- Pixel purchase event handling
- Delegation memory creation
- Rate limiting and throttling
- Connection recovery
- Event deduplication
- Error handling
Key Functionality to Test
1. Connection Management
- Establishing WebSocket connection
- Connection authentication
- Reconnection logic
- Connection monitoring
- Graceful disconnection
2. Event Handling
- Receiving pixel.bought events
- Parsing event data
- Validating event structure
- Event routing
- Event acknowledgment
3. Pixel Purchase Processing
- Extracting purchase details
- Creating post content
- Triggering post generation
- Rate limiting posts
- Deduplication logic
4. Memory Integration
- Creating delegation memories
- Storing purchase references
- Memory configuration
- Memory cleanup
Testing Strategy
describe('LNPixels Listener', () => {
describe('Connection Management', () => {
test('establishes WebSocket connection');
test('handles connection errors');
test('implements reconnection logic');
test('monitors connection health');
test('disconnects gracefully');
});
describe('Event Handling', () => {
test('receives pixel.bought events');
test('parses event data correctly');
test('validates event structure');
test('routes events appropriately');
test('handles malformed events');
});
describe('Pixel Purchase Processing', () => {
test('extracts purchase details');
test('triggers post generation');
test('applies rate limiting');
test('deduplicates purchases');
test('respects posting intervals');
});
describe('Memory Integration', () => {
test('creates delegation memories when enabled');
test('skips memories when disabled');
test('stores purchase references');
test('handles memory creation errors');
});
describe('Error Handling', () => {
test('handles connection failures');
test('recovers from network errors');
test('continues after processing errors');
test('logs errors appropriately');
});
describe('Integration', () => {
test('integrates with service posting');
test('uses event emitter bridge');
test('respects configuration');
});
});Test Fixtures Needed
- Mock WebSocket connections
- Sample pixel.bought events
- Purchase data examples
- Configuration variations
- Error scenarios
Acceptance Criteria
- Connection management fully tested
- Event handling verified
- Purchase processing covered
- Memory integration tested
- Error handling verified
- Rate limiting tested
- Overall coverage 100%
Related
- Parent: Increase plugin-nostr test coverage to 100% #39 - Increase plugin-nostr test coverage to 100%
- Related:
lib/service.js- Consumes pixel events - Related:
lib/bridge.js- Event emitter - See:
test/service.pixelBought.test.js
Priority
🟡 MEDIUM - Important for LNPixels integration and pixel purchase responses.
Copilot