From 28b79a76a874d329c53068976ecf2d69e7536c1d Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 27 Aug 2020 16:42:07 +0200 Subject: [PATCH] test: fix pubsub intermittent test (#741) --- test/pubsub/operation.node.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/pubsub/operation.node.js b/test/pubsub/operation.node.js index 450f614b..08e2afbc 100644 --- a/test/pubsub/operation.node.js +++ b/test/pubsub/operation.node.js @@ -311,7 +311,11 @@ describe('Pubsub subsystem operates correctly', () => { expect(handlerSpy.args.map(([message]) => uint8ArrayToString(message.data))).to.include.members(['message1', 'message2']) // Disconnect the first connection (this acts as a delayed reconnect) + const libp2pConnUpdateSpy = sinon.spy(libp2p.connectionManager.connections, 'set') + const remoteLibp2pConnUpdateSpy = sinon.spy(remoteLibp2p.connectionManager.connections, 'set') + await originalConnection.close() + await pWaitFor(() => libp2pConnUpdateSpy.callCount === 1 && remoteLibp2pConnUpdateSpy.callCount === 1) // Verify messages go both ways after the disconnect handlerSpy.resetHistory()