Read a receipt reporting a transient state as non-final too, so the merge waits for the real one

This commit is contained in:
2026-09-03 19:28:08 +02:00
parent dd458bfa53
commit 42e6e97447
6 changed files with 77 additions and 16 deletions
+18 -11
View File
@@ -98,22 +98,23 @@ describe('dlrFromPdu()', () => {
});
test('maps every spec status code back to its message state and id', () => {
for (const [code, expected, statusId] of [
['DELIVRD', 'DELIVERED', 2],
['UNDELIV', 'UNDELIVERABLE', 5],
['EXPIRED', 'EXPIRED', 3],
['DELETED', 'DELETED', 4],
['ACCEPTD', 'ACCEPTED', 6],
['REJECTD', 'REJECTED', 8],
['ENROUTE', 'ENROUTE', 1],
['UNKNOWN', 'UNKNOWN', 7],
['delivrd', 'DELIVERED', 2],
for (const [code, expected, statusId, intermediate] of [
['DELIVRD', 'DELIVERED', 2, false],
['UNDELIV', 'UNDELIVERABLE', 5, false],
['EXPIRED', 'EXPIRED', 3, false],
['DELETED', 'DELETED', 4, false],
['ACCEPTD', 'ACCEPTED', 6, false],
['REJECTD', 'REJECTED', 8, false],
['ENROUTE', 'ENROUTE', 1, true],
['UNKNOWN', 'UNKNOWN', 7, false],
['delivrd', 'DELIVERED', 2, false],
] as const) {
const dlr = dlrFromPdu(deliverSm(`id:x stat:${code} err:0`));
assert.ok(dlr);
assert.equal(dlr.statusMsg, expected);
assert.equal(dlr.statusId, statusId);
assert.equal(dlr.intermediate, intermediate);
}
});
@@ -207,7 +208,7 @@ describe('dlrFromPdu()', () => {
}
});
test('reads an intermediate delivery notification as a report, marked as one', () => {
test('reads a report the peer marked non-final, by either spelling', () => {
const enroute = 'id:0195f0c7 sub:001 dlvrd:000 submit date:2508251430 done date:2508251431 stat:ENROUTE err:000 text:';
const dlr = dlrFromPdu(deliverSm(enroute, undefined, consts.ESM_CLASS.INTERMEDIATE_DELIVERY));
@@ -220,6 +221,12 @@ describe('dlrFromPdu()', () => {
assert.ok(unreadable, 'the marker makes it a report whatever the body parses to');
assert.equal(unreadable.intermediate, true);
const scheduled = dlrFromPdu(deliverSm('id:0195f0c7', { message_state: { tagValue: 0 } }));
assert.ok(scheduled);
assert.equal(scheduled.statusMsg, 'SCHEDULED');
assert.equal(scheduled.intermediate, true, 'an ordinary receipt reporting a transient state is not final either');
});
test('exposes the raw receipt alongside the resolved fields', () => {