mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-14 01:31:22 +00:00
fix: await unhandle of protocols (#1144)
To allow us to shut down cleanly, we must wait the unhandling of protocols - this is because they write the new list of protocols into the datastore which might also be in the process of shutting down.
This commit is contained in:
@ -371,7 +371,7 @@ describe('libp2p.upgrader', () => {
|
||||
expect(libp2p.upgrader).to.equal(libp2p.transportManager.upgrader)
|
||||
})
|
||||
|
||||
it('should be able to register and unregister a handler', () => {
|
||||
it('should be able to register and unregister a handler', async () => {
|
||||
libp2p = new Libp2p({
|
||||
peerId: peers[0],
|
||||
modules: {
|
||||
@ -384,11 +384,11 @@ describe('libp2p.upgrader', () => {
|
||||
expect(libp2p.upgrader.protocols).to.not.have.any.keys(['/echo/1.0.0', '/echo/1.0.1'])
|
||||
|
||||
const echoHandler = () => {}
|
||||
libp2p.handle(['/echo/1.0.0', '/echo/1.0.1'], echoHandler)
|
||||
await libp2p.handle(['/echo/1.0.0', '/echo/1.0.1'], echoHandler)
|
||||
expect(libp2p.upgrader.protocols.get('/echo/1.0.0')).to.equal(echoHandler)
|
||||
expect(libp2p.upgrader.protocols.get('/echo/1.0.1')).to.equal(echoHandler)
|
||||
|
||||
libp2p.unhandle(['/echo/1.0.0'])
|
||||
await libp2p.unhandle(['/echo/1.0.0'])
|
||||
expect(libp2p.upgrader.protocols.get('/echo/1.0.0')).to.equal(undefined)
|
||||
expect(libp2p.upgrader.protocols.get('/echo/1.0.1')).to.equal(echoHandler)
|
||||
})
|
||||
|
Reference in New Issue
Block a user