From 098891bb84bbf217a81a12ce80fafb37e00961f9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 30 Aug 2026 22:17:27 +0200 Subject: [PATCH] Cover the enquire_link we answer and stop draining a peer that answers nothing --- AGENTS.md | 5 +++-- test/session.test.ts | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0f6aa42..b0e334a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -161,8 +161,9 @@ exactly 140. listener; anything else takes a bare `t.after`. Its close aborts rather than drains, so a test that fails holding the send window still ends. - `t.after` hooks run in registration order, so registering at creation tears the outermost resource - down first — the wrong way round for a listener, which blocks until every connection on it is gone. - A listener's own hook goes last, after the hooks that close what is connected to it. + down first. A teardown that waits on a listener must destroy that listener's own connections before + it waits, or be registered after the hook that does — `net.Server.close()` does not call back until + every connection on it is gone. - `assert.equal` from `node:assert/strict` narrows its first argument, so a following `?.` on the same value is flagged as unnecessary. Assert once with `assert.ok(x)` and use plain access after. diff --git a/test/session.test.ts b/test/session.test.ts index d42636d..5565ef5 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -298,6 +298,21 @@ describe('bind', () => { assert.equal(await responded, '00000010800000150000000400000001'); }); + test('answers the enquire_link a bound peer sends', async t => { + const smpp = await startServer(t); + const peer = rawPeer(t, smpp.port); + + peer.write(bindOf(0x34)); + await peer.next(); + peer.write({ cmdName: 'enquire_link', seqNr: 2 }); + + const answered = await peer.next(); + + assert.equal(answered.cmdName, 'enquire_link_resp'); + assert.equal(answered.cmdStatus, 'ESME_ROK'); + assert.equal(answered.seqNr, 2); + }); + test('declares SMPP 3.4 by default and the version the caller asks for', async t => { const smpp = await startServer(t); const declared: (number | undefined)[] = []; @@ -1094,7 +1109,8 @@ describe('robustness', () => { assert.ok(session); - const held = session.sendSms({ from: '46701113311', message: 'holds the slot', to: '46709771337' }); + void session.sendSms({ from: '46701113311', message: 'holds the slot', to: '46709771337' }); + const controller = new AbortController(); controller.abort(); @@ -1107,9 +1123,6 @@ describe('robustness', () => { assert.notEqual(aborted, false, 'an aborted send should not wait for the window'); assert.ok(aborted !== false && aborted.err instanceof Error); - - await session.close(); - await held; }); // A socket the loop opened and never handed over is one leaked per retry, forever.