Leave an unknown notation alone and read a receipt's TLV as the id the submit answered

This commit is contained in:
2026-08-30 23:01:39 +02:00
parent 696e018b77
commit 706b61d6ca
11 changed files with 70 additions and 39 deletions
+14 -7
View File
@@ -208,28 +208,35 @@ describe('dlrFromPdu()', () => {
});
test('reads the id in the notation the peer writes receipts in', () => {
const hex = dlrFromPdu(deliverSm('id:1a2B stat:DELIVRD err:000 text:'), 'hex');
const hex = dlrFromPdu(deliverSm('id:1a2B stat:DELIVRD err:000 text:'), { receipt: 'hex' });
assert.ok(hex);
assert.equal(hex.smsId, '6699');
assert.equal(hex.receipt?.id, '1a2B', 'the receipt itself keeps the id as it arrived');
assert.equal(dlrFromPdu(deliverSm('id:0000123 stat:DELIVRD'), 'decimal')?.smsId, '123');
assert.equal(dlrFromPdu(deliverSm('nothing scrapable here', {
assert.equal(dlrFromPdu(deliverSm('id:0000123 stat:DELIVRD'), { receipt: 'decimal' })?.smsId, '123');
});
// SMPP 3.4 5.3.2.26 makes the TLV the id the submit_sm_resp carried, not the body's rendering.
test('reads the receipted_message_id TLV in the notation the peer answers a submit in', () => {
const marked = deliverSm('nothing scrapable here', {
receipted_message_id: { tagValue: 'FF' },
}, 0), 'hex')?.smsId, '255');
}, 0);
assert.equal(dlrFromPdu(marked, { submitResp: 'hex' })?.smsId, '255');
assert.equal(dlrFromPdu(marked, { receipt: 'hex' })?.smsId, 'FF');
});
test('leaves an id the notation cannot read as it arrived', () => {
assert.equal(dlrFromPdu(deliverSm('id:beef-1 stat:DELIVRD'), 'hex')?.smsId, 'beef-1');
assert.equal(dlrFromPdu(deliverSm('id:1a2b stat:DELIVRD'), 'decimal')?.smsId, '1a2b');
assert.equal(dlrFromPdu(deliverSm('id:beef-1 stat:DELIVRD'), { receipt: 'hex' })?.smsId, 'beef-1');
assert.equal(dlrFromPdu(deliverSm('id:1a2b stat:DELIVRD'), { receipt: 'decimal' })?.smsId, '1a2b');
assert.equal(dlrFromPdu(deliverSm('id:0195f0c7 stat:DELIVRD'))?.smsId, '0195f0c7');
});
// Number() reads 9007199254740993 as ...92, which correlates a receipt to the wrong send.
test('reads an id past the safe integer range without losing a digit', () => {
assert.equal(
dlrFromPdu(deliverSm('id:9007199254740993 stat:DELIVRD'), 'decimal')?.smsId,
dlrFromPdu(deliverSm('id:9007199254740993 stat:DELIVRD'), { receipt: 'decimal' })?.smsId,
'9007199254740993',
);
});