Tell a refused PDU apart from a session that failed (#82)

* Regression tests for telling a refused PDU from a failed session

* Export PduRefusedError so a refusal can be told from a session failure

* Document telling a refused PDU from a session failure

* Share the malformed-PDU fixtures and pin that a dead stream is no refusal

* Say once what a refusal is, and why the header type is published

* Fold the refused-response test into the one that already staged it

* Drop the refusal-rate claim the interop finding does not support

* Build a raw PDU one way, sequence number included

* Follow PduRefusedError into pdu-refusal.ts
This commit is contained in:
2026-09-05 23:16:59 +02:00
committed by GitHub
parent afe188eecd
commit db02f0058d
9 changed files with 296 additions and 50 deletions
+6 -3
View File
@@ -20,12 +20,13 @@ import { LinkGate } from '../src/link-gate.ts';
import { Reassembler, decodeSegments } from '../src/reassembly.ts';
import { Session } from '../src/session.ts';
import { DlrMerger } from '../src/dlr-merger.ts';
import { PduRefusedError } from '../src/pdu-refusal.ts';
import { objToPdu } from '../src/pdu.ts';
import { checkSessionOptions } from '../src/session-options.ts';
import { client } from '../src/client.ts';
import { closeAfter, closeListenerAfter } from './teardown.ts';
import { consts } from '../src/defs/constants.ts';
import { errors } from '../src/defs/errors.ts';
import { objToPdu } from '../src/pdu.ts';
import { paramNumber, paramText } from '../src/defs/types.ts';
import { server } from '../src/server.ts';
import { silentLog } from '../src/log.ts';
@@ -499,14 +500,16 @@ describe('reconnect', () => {
const events: string[] = [];
session.on('close', () => { events.push('close'); });
session.on('sessionError', () => { events.push('sessionError'); });
session.on('sessionError', err => {
events.push(err instanceof PduRefusedError ? 'refused' : 'sessionError');
});
const reconnected = once<true>(resolve => { session.on('reconnected', () => { resolve(true); }); });
peerOf(smpp).sock.write(unreadablePdu);
await reconnected;
assert.deepEqual(events, ['sessionError']);
assert.deepEqual(events, ['sessionError'], 'an unframeable stream is the link dying, not one PDU refused');
});
test('refuses a backoff that would retry without pausing', () => {