Skip to content

Add comprehensive tests for dmsg packages#348

Merged
0pcom merged 1 commit intoskycoin:developfrom
0pcom:add-tests
Mar 20, 2026
Merged

Add comprehensive tests for dmsg packages#348
0pcom merged 1 commit intoskycoin:developfrom
0pcom:add-tests

Conversation

@0pcom
Copy link
Collaborator

@0pcom 0pcom commented Mar 20, 2026

e2e-style tests (pkg/dmsgtest/e2e_test.go):

  • TestBidirectionalStreams: bidirectional data transfer at 32B/4KB/64KB
  • TestMultiServerStreams: streams across multiple servers and clients
  • TestConcurrentStreams: 20 simultaneous streams with data integrity
  • TestSessionReconnect: client reconnects after server shutdown
  • TestListenerAcceptAll: listener accepts multiple connections
  • TestPortOccupied: duplicate listen returns ErrPortOccupied
  • TestDialNonexistentClient: dial unknown PK returns ErrDiscEntryNotFound

direct client tests (pkg/direct/client_test.go):

  • Entry lookup, post, delete, put operations
  • AvailableServers/AllServers filtering
  • AllEntries enumeration
  • ClientsByServer/AllClientsByServer grouping
  • GetClientEntry and GetAllEntries utility functions

ioutil tests (pkg/ioutil/buf_read_test.go):

  • BufRead with exact fit, short buffer, empty data, large data

noise nonce tests (pkg/noise/nonce_test.go):

  • DecryptWithNonceMap replay prevention
  • Out-of-order decryption with nonce map
  • Encrypt/decrypt roundtrip
  • Large payload (64KB) roundtrip

e2e-style tests (pkg/dmsgtest/e2e_test.go):
- TestBidirectionalStreams: bidirectional data transfer at 32B/4KB/64KB
- TestMultiServerStreams: streams across multiple servers and clients
- TestConcurrentStreams: 20 simultaneous streams with data integrity
- TestSessionReconnect: client reconnects after server shutdown
- TestListenerAcceptAll: listener accepts multiple connections
- TestPortOccupied: duplicate listen returns ErrPortOccupied
- TestDialNonexistentClient: dial unknown PK returns ErrDiscEntryNotFound

direct client tests (pkg/direct/client_test.go):
- Entry lookup, post, delete, put operations
- AvailableServers/AllServers filtering
- AllEntries enumeration
- ClientsByServer/AllClientsByServer grouping
- GetClientEntry and GetAllEntries utility functions

ioutil tests (pkg/ioutil/buf_read_test.go):
- BufRead with exact fit, short buffer, empty data, large data

noise nonce tests (pkg/noise/nonce_test.go):
- DecryptWithNonceMap replay prevention
- Out-of-order decryption with nonce map
- Encrypt/decrypt roundtrip
- Large payload (64KB) roundtrip
@0pcom 0pcom merged commit e5ee528 into skycoin:develop Mar 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant