Let the session own its bind state, written by bound() alone #42

Merged
lilleman merged 11 commits from session-bound into main 2026-09-28 04:37:29 +02:00
Showing only changes of commit 9eebd42887 - Show all commits
+5 -6
View File
@@ -463,12 +463,11 @@ describe('bind', () => {
assert.deepEqual(session.bound('transmitter', undefined), {});
assert.equal(session.peerInterfaceVersion, 0x00, 'no declared version is pre-3.4');
// The mistakes an untyped caller makes: the TLV object for its value, a version past int8, a typo.
for (const [bindType, declared] of [['receiver', { tagValue: 0x34 }], ['receiver', 0x100], ['receiver', 3.4], ['tx', 0x34]]) {
const refused: unknown = Reflect.apply(Reflect.get(session, 'bound'), session, [bindType, declared]);
assert.ok(refused && typeof refused === 'object' && 'err' in refused && refused.err instanceof Error);
}
// The likeliest mistakes: the TLV object for its value, a version past int8, the command's name.
assert.match(session.bound('receiver', { tagValue: 0x34 }).err?.message ?? '', /tagValue, or undefined .* got object$/);
assert.ok(session.bound('receiver', 0x100).err);
assert.ok(session.bound('receiver', 3.4).err);
assert.match(session.bound('bind_receiver', 0x34).err?.message ?? '', /without "bind_", got "bind_receiver"$/);
assert.equal(session.boundAs, 'transmitter', 'a refused bind leaves the recorded one alone');
assert.equal(session.peerInterfaceVersion, 0x00);