Decompose the codec, document the session surface and record the review decisions

This commit is contained in:
2026-08-26 22:59:39 +02:00
parent 6d842a8539
commit 435fa42708
10 changed files with 186 additions and 96 deletions
+16 -13
View File
@@ -84,20 +84,23 @@ describe('dlrFromPdu()', () => {
assert.equal(dlr.doneDate?.toISOString(), '2025-08-25T14:31:00.000Z');
});
test('maps every spec status code back to its message state', () => {
for (const [code, expected] of [
['DELIVRD', 'DELIVERED'],
['UNDELIV', 'UNDELIVERABLE'],
['EXPIRED', 'EXPIRED'],
['DELETED', 'DELETED'],
['ACCEPTD', 'ACCEPTED'],
['REJECTD', 'REJECTED'],
['ENROUTE', 'ENROUTE'],
['UNKNOWN', 'UNKNOWN'],
]) {
const dlr = dlrFromPdu(deliverSm(`id:x stat:${String(code)} err:0`));
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],
] as const) {
const dlr = dlrFromPdu(deliverSm(`id:x stat:${code} err:0`));
assert.equal(dlr?.statusMsg, expected);
assert.ok(dlr);
assert.equal(dlr.statusMsg, expected);
assert.equal(dlr.statusId, statusId);
}
});
+15
View File
@@ -120,6 +120,21 @@ describe('encoding submit_sm', () => {
);
});
test('encodes a string short_message with the given data_coding instead of a detected one', () => {
const pdu = encode({
cmdName: 'submit_sm',
params: {
data_coding: 0x08,
destination_addr: '46709771337',
short_message: 'hi',
source_addr: '46701113311',
},
seqNr: 12,
});
assert.equal(pdu.subarray(-7).toString('hex'), '08000400680069');
});
test('keeps a UDH-carrying short_message as a buffer', () => {
const message = Buffer.concat([
Buffer.from('050003010101', 'hex'),