Skip to main content

smpp-connector — Testing Strategy

Status: populated | Last updated: 2026-04-18

1. Coverage Target

Minimum 80% line coverage enforced in CI.

2. Test Pyramid

2.1 Unit Tests

Framework: Jest + ts-jest

What to unit-test:

  • SmppPduEncoder: encode submit_sm for GSM7, UCS2, long CSMS, long TLV.
  • SmppPduDecoder: decode deliver_sm DLR PDUs with various text formats.
  • TpsThrottleService: sliding-window logic with mock Redis pipeline.
  • ReconnectScheduler: backoff calculation (5→10→20→40→60 s cap).
  • DlrParser: extract message_state and receipted_message_id from short_message text and from TLV optional parameters.
  • MessageCorrelationRepository: unit test with mock PostgreSQL client.

Key test cases:

describe('TpsThrottleService', () => {
it('allows requests when count is below tpsLimit', () => {});
it('denies requests when count equals tpsLimit', () => {});
it('resets window on next second boundary', () => {});
});

describe('ReconnectScheduler', () => {
it('returns 5000ms for attempt 1', () => {});
it('returns 60000ms for attempt 5+', () => {});
it('resets to 0 after successful bind', () => {});
});

describe('SmppPduEncoder', () => {
it('encodes GSM7 message within single PDU (≤160 chars)', () => {});
it('splits GSM7 long message into CSMS segments', () => {});
it('encodes UCS2 message with TLV strategy', () => {});
it('uses data_coding 0x08 for UCS2', () => {});
});

2.2 Integration Tests

Framework: Jest + testcontainers (PostgreSQL, Redis) + mock SMPP server

Mock SMPP server: Use a lightweight in-process SMPP server (e.g. node-smpp test utility) to simulate MNO behaviour.

What to integration-test:

  • Full bind → submit_sm → submit_sm_resp → DLR flow with mock SMPP server.
  • TPS throttle: publish 110 NATS messages with tpsLimit=100; verify 10 are NAKed.
  • Reconnect: mock SMPP server drops connection; verify exponential backoff and re-bind.
  • DLR correlation: submit_sm → write correlation → receive deliver_sm → verify sms.dlr.inbound published with correct messageId.
  • enquire_link heartbeat: mock SMPP server doesn't respond; verify UNBOUND event published after 10 s timeout.
  • Primary/backup failover: primary mock SMPP server goes offline; verify backup bind attempt.

2.3 Contract Tests (Event Schema)

Framework: Pact (NATS message contract)

  • dlr-processor publishes a Pact consumer contract for DlrInboundEvent.
  • smpp-connector CI pipeline runs the provider verification step.
  • Ensures schema changes to DlrInboundEvent don't silently break dlr-processor.

2.4 SMPP Protocol Compliance Tests

Scope: Verify PDU encoding/decoding against SMPP 3.4 specification.

  • Use Wireshark captures from a reference SMPP server (Logica SMSC simulator or OpenSMPP).
  • Verify byte layout for: bind_transceiver, submit_sm (GSM7, UCS2, CSMS, TLV), deliver_sm.
  • These are run manually before each major release.

3. CI Pipeline Gates

StageToolPass criteria
Unit testsJestAll pass; ≥ 80% coverage
Integration testsJest + TestcontainersAll pass
Contract verificationPactProvider verification passes
LintESLint0 errors
Type checktsc --noEmit0 errors
Protocol smoke testghz / nats-test harness100 msgs dispatched and DLR received in staging