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: encodesubmit_smfor GSM7, UCS2, long CSMS, long TLV.SmppPduDecoder: decodedeliver_smDLR PDUs with various text formats.TpsThrottleService: sliding-window logic with mock Redis pipeline.ReconnectScheduler: backoff calculation (5→10→20→40→60 s cap).DlrParser: extractmessage_stateandreceipted_message_idfromshort_messagetext 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.inboundpublished with correctmessageId. enquire_linkheartbeat: 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-processorpublishes a Pact consumer contract forDlrInboundEvent.smpp-connectorCI pipeline runs the provider verification step.- Ensures schema changes to
DlrInboundEventdon't silently breakdlr-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
| Stage | Tool | Pass criteria |
|---|---|---|
| Unit tests | Jest | All pass; ≥ 80% coverage |
| Integration tests | Jest + Testcontainers | All pass |
| Contract verification | Pact | Provider verification passes |
| Lint | ESLint | 0 errors |
| Type check | tsc --noEmit | 0 errors |
| Protocol smoke test | ghz / nats-test harness | 100 msgs dispatched and DLR received in staging |