mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-12 00:31:22 +00:00
refactor: circuit relay to async (#477)
* refactor: add dialing over relay support * chore: fix lint * fix: dont clear listeners on close * fix: if dial errors already have codes, just rethrow them * fix: clear the registrar when libp2p stops * fix: improve connection maintenance with circuit * chore: correct feedback * test: use chai as promised * test(fix): reset multiaddrs on dial test
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
const chai = require('chai')
|
||||
chai.use(require('dirty-chai'))
|
||||
chai.use(require('chai-as-promised'))
|
||||
const { expect } = chai
|
||||
const sinon = require('sinon')
|
||||
|
||||
@ -98,20 +99,18 @@ describe('Identify', () => {
|
||||
sinon.stub(localConnectionMock, 'newStream').returns({ stream: local, protocol: multicodecs.IDENTIFY })
|
||||
|
||||
// Run identify
|
||||
try {
|
||||
await Promise.all([
|
||||
localIdentify.identify(localConnectionMock, localPeer.id),
|
||||
remoteIdentify.handleMessage({
|
||||
connection: remoteConnectionMock,
|
||||
stream: remote,
|
||||
protocol: multicodecs.IDENTIFY
|
||||
})
|
||||
])
|
||||
expect.fail('should have thrown')
|
||||
} catch (err) {
|
||||
expect(err).to.exist()
|
||||
expect(err.code).to.eql(Errors.ERR_INVALID_PEER)
|
||||
}
|
||||
const identifyPromise = Promise.all([
|
||||
localIdentify.identify(localConnectionMock, localPeer.id),
|
||||
remoteIdentify.handleMessage({
|
||||
connection: remoteConnectionMock,
|
||||
stream: remote,
|
||||
protocol: multicodecs.IDENTIFY
|
||||
})
|
||||
])
|
||||
|
||||
await expect(identifyPromise)
|
||||
.to.eventually.be.rejected()
|
||||
.and.to.have.property('code', Errors.ERR_INVALID_PEER)
|
||||
})
|
||||
|
||||
describe('push', () => {
|
||||
@ -229,6 +228,7 @@ describe('Identify', () => {
|
||||
|
||||
// Wait for identify to finish
|
||||
await libp2p.dialer.identifyService.identify.firstCall.returnValue
|
||||
sinon.stub(libp2p, 'isStarted').returns(true)
|
||||
|
||||
libp2p.handle('/echo/2.0.0', () => {})
|
||||
libp2p.unhandle('/echo/2.0.0')
|
||||
|
Reference in New Issue
Block a user