Skip to content

Commit 3cbbc8d

Browse files
committed
test: add test for noReply call option
1 parent dd712d8 commit 3cbbc8d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/client.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,34 @@ describe('RPCClient', function(){
15651565

15661566
});
15671567

1568+
it('should emit badMessage upon a response to a noReply call', async () => {
1569+
1570+
const echoPayload = {abc: 123};
1571+
const {endpoint, close} = await createServer();
1572+
const cli = new RPCClient({
1573+
endpoint,
1574+
identity: 'X',
1575+
});
1576+
1577+
try {
1578+
await cli.connect();
1579+
1580+
const res = await cli.call('Echo', echoPayload, {noReply: true});
1581+
const [bad] = await once(cli, 'badMessage');
1582+
1583+
const [mType, mId, mVal] = JSON.parse(bad.buffer.toString('utf8'));
1584+
1585+
assert.equal(mType, 3);
1586+
assert.deepEqual(mVal, echoPayload);
1587+
assert.equal(res, undefined);
1588+
1589+
} finally {
1590+
await cli.close();
1591+
close();
1592+
}
1593+
1594+
});
1595+
15681596
});
15691597

15701598

0 commit comments

Comments
 (0)