Cover the guarded address writers, and cut what the code already says
Mirror / push (push) Successful in 5s
Test / lint (pull_request) Successful in 22s
Test / test (18) (pull_request) Successful in 29s
Test / test (20) (pull_request) Successful in 30s
Test / test (22) (pull_request) Successful in 37s
Test / test (24) (pull_request) Successful in 29s
Test / test (26) (pull_request) Successful in 30s

This commit is contained in:
2026-09-21 08:08:42 +02:00
parent c1e0407942
commit f870b7530f
8 changed files with 68 additions and 45 deletions
+24
View File
@@ -345,6 +345,30 @@ describe('a body the PDU\'s own data_coding cannot carry', () => {
});
});
describe('an address the field cannot carry', () => {
test('refuses it through sendSms(), with nothing reaching the socket', async t => {
const smsc = await dummySmsc(t);
const session = await bindToSmsc(t, smsc.port, { reconnect: false });
const refusals: [string, RegExp][] = [
['46701113311\u0000EVIL', /U\+0000 at index 11/],
['Kaffe一', /U\+4E00 at index 5/],
['😀', /U\+1F600 at index 0/],
];
for (const [sender, names] of refusals) {
const sent = await session.sendSms({ from: sender, message: 'Hello world', to });
assert.ok(sent.err instanceof Error, sender);
assert.match(sent.err.message, /source_addr/);
assert.match(sent.err.message, names);
assert.deepEqual(sent.smsIds, [], sender);
}
assert.deepEqual(smsc.octets, [], 'an address the field cannot carry never reaches the socket');
});
});
describe('a time no peer can read', () => {
const invalid = new Date('nope');