This guide covers the testing infrastructure and procedures for the Nostr relay server.
Our comprehensive test suite verifies compliance with Nostr Implementation Possibilities (NIPs). These tests ensure our relay correctly implements the Nostr protocol specifications.
- NIP-01: Basic protocol flow
- NIP-02: Contact List
- NIP-04: Encrypted Direct Message
- NIP-11: Relay Information
- NIP-28: Public Chat
- NIP-42: Authentication
For detailed NIP implementations, see our Technical Specifications.
We maintain both client-side and server-side WebSocket tests to ensure robust connection handling:
- Connection establishment and maintenance
- Message sending and receiving
- Protocol-specific message formatting
- Error handling and recovery
- Client connection management
- Message routing and processing
- Connection cleanup
- Load handling
test/
├── client/
│ ├── test-nostr.js # Tests using nostr-tools
│ └── test-relay.js # Raw WebSocket client tests
└── server/
├── websocket/
│ └── test-ws-server.js
└── e2e/
└── nips/
└── nips.test.js
Test the relay from a client perspective:
# Test using nostr-tools
node test/client/test-nostr.js
# Test raw WebSocket connection
node test/client/test-relay.jsVerify server functionality:
# Test WebSocket server
node test/server/websocket/test-ws-server.js
# Run NIP compliance tests
npm run test:e2e:nips-
Run Full Suite Before Deployment
npm run test:all
-
Test Specific NIPs
npm run test:nips -- --nip=1 # Test NIP-01 -
Monitor Test Coverage
- Keep coverage above 80%
- Focus on critical path testing
- Include edge cases
When adding new functionality:
-
NIP Implementation Tests
- Add to
test/e2e/nips/ - Follow existing NIP test patterns
- Include both success and failure cases
- Add to
-
WebSocket Tests
- Add client tests if adding client-facing features
- Add server tests for new server functionality
- Test both normal operation and error conditions
Our CI pipeline automatically runs all tests on:
- Pull requests
- Merges to main branch
- Release tags
See our Deployment Guide for more details on the CI/CD process.