mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-21 04:51:33 +00:00
refactor: async identify and identify push (#473)
* chore: add missing dep * feat: import from identify push branch https://github.com/libp2p/js-libp2p-identify/tree/feat/identify-push * feat: add the connection to stream handlers * refactor: identify to async/await * chore: fix lint * test: add identify tests * refactor: add identify to the dialer flow * feat: connect identify to the registrar * fix: resolve review feedback * fix: perform identify push when our protocols change
This commit is contained in:
@ -218,5 +218,28 @@ describe('Dialing (direct, WebSockets)', () => {
|
||||
await connection.close()
|
||||
expect(libp2p.dialer.connectToMultiaddr.callCount).to.equal(1)
|
||||
})
|
||||
|
||||
it('should run identify automatically after connecting', async () => {
|
||||
libp2p = new Libp2p({
|
||||
peerInfo,
|
||||
modules: {
|
||||
transport: [Transport],
|
||||
streamMuxer: [Muxer],
|
||||
connEncryption: [Crypto]
|
||||
}
|
||||
})
|
||||
|
||||
sinon.spy(libp2p.dialer.identifyService, 'identify')
|
||||
sinon.spy(libp2p.peerStore, 'update')
|
||||
|
||||
const connection = await libp2p.dialer.connectToMultiaddr(remoteAddr)
|
||||
expect(connection).to.exist()
|
||||
// Wait for setImmediate to trigger the identify call
|
||||
await delay(1)
|
||||
expect(libp2p.dialer.identifyService.identify.callCount).to.equal(1)
|
||||
await libp2p.dialer.identifyService.identify.firstCall.returnValue
|
||||
|
||||
expect(libp2p.peerStore.update.callCount).to.equal(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user