mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-08-01 00:41:57 +00:00
chore: add typedefs (#802)
This commit is contained in:
committed by
Vasco Santos
parent
7809e6444e
commit
169bb806a7
@@ -10,7 +10,7 @@ const AggregateError = require('aggregate-error')
|
||||
const pDefer = require('p-defer')
|
||||
const delay = require('delay')
|
||||
|
||||
const { DialRequest } = require('../../src/dialer/dial-request')
|
||||
const DialRequest = require('../../src/dialer/dial-request')
|
||||
const createMockConnection = require('../utils/mockConnection')
|
||||
const error = new Error('dial failes')
|
||||
|
||||
|
@@ -12,7 +12,8 @@ const pWaitFor = require('p-wait-for')
|
||||
const unit8ArrayToString = require('uint8arrays/to-string')
|
||||
|
||||
const { codes: Errors } = require('../../src/errors')
|
||||
const { IdentifyService, multicodecs } = require('../../src/identify')
|
||||
const IdentifyService = require('../../src/identify')
|
||||
const multicodecs = IdentifyService.multicodecs
|
||||
const Peers = require('../fixtures/peers')
|
||||
const Libp2p = require('../../src')
|
||||
const Envelope = require('../../src/record/envelope')
|
||||
@@ -54,7 +55,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: localPeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
const remoteIdentify = new IdentifyService({
|
||||
@@ -63,7 +65,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: remotePeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -109,7 +112,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: localPeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -119,7 +123,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: remotePeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -167,7 +172,8 @@ describe('Identify', () => {
|
||||
peerId: localPeer,
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: localPeerStore,
|
||||
multiaddrs: []
|
||||
multiaddrs: [],
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
const remoteIdentify = new IdentifyService({
|
||||
@@ -175,7 +181,8 @@ describe('Identify', () => {
|
||||
peerId: remotePeer,
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: remotePeerStore,
|
||||
multiaddrs: []
|
||||
multiaddrs: [],
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -246,7 +253,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: localPeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -259,7 +267,8 @@ describe('Identify', () => {
|
||||
connectionManager,
|
||||
peerStore: remotePeerStore,
|
||||
multiaddrs: [],
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -316,7 +325,8 @@ describe('Identify', () => {
|
||||
connectionManager: new EventEmitter(),
|
||||
peerStore: localPeerStore,
|
||||
multiaddrs: listenMaddrs,
|
||||
isStarted: () => true
|
||||
isStarted: () => true,
|
||||
_options: { host: {} }
|
||||
}
|
||||
})
|
||||
|
||||
|
@@ -6,7 +6,6 @@ chai.use(require('chai-bytes'))
|
||||
const uint8arrayFromString = require('uint8arrays/from-string')
|
||||
const uint8arrayEquals = require('uint8arrays/equals')
|
||||
const Envelope = require('../../src/record/envelope')
|
||||
const Record = require('libp2p-interfaces/src/record')
|
||||
const { codes: ErrorCodes } = require('../../src/errors')
|
||||
|
||||
const peerUtils = require('../utils/creators/peer')
|
||||
@@ -14,9 +13,10 @@ const peerUtils = require('../utils/creators/peer')
|
||||
const domain = 'libp2p-testing'
|
||||
const codec = uint8arrayFromString('/libp2p/testdata')
|
||||
|
||||
class TestRecord extends Record {
|
||||
class TestRecord {
|
||||
constructor (data) {
|
||||
super(domain, codec)
|
||||
this.domain = domain
|
||||
this.codec = codec
|
||||
this.data = data
|
||||
}
|
||||
|
||||
|
@@ -51,8 +51,6 @@ describe('Transport Manager (TCP)', () => {
|
||||
})
|
||||
|
||||
it('should be able to listen', async () => {
|
||||
sinon.spy(tm, '_createSelfPeerRecord')
|
||||
|
||||
tm.add(Transport.prototype[Symbol.toStringTag], Transport, { listenerOptions: { listen: 'carefully' } })
|
||||
const transport = tm._transports.get(Transport.prototype[Symbol.toStringTag])
|
||||
const spyListener = sinon.spy(transport, 'createListener')
|
||||
|
@@ -56,28 +56,6 @@ describe('Upgrader', () => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
it('should ignore a missing remote peer id', async () => {
|
||||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })
|
||||
|
||||
const muxers = new Map([[Muxer.multicodec, Muxer]])
|
||||
sinon.stub(localUpgrader, 'muxers').value(muxers)
|
||||
sinon.stub(remoteUpgrader, 'muxers').value(muxers)
|
||||
|
||||
const cryptos = new Map([[Crypto.protocol, Crypto]])
|
||||
sinon.stub(localUpgrader, 'cryptos').value(cryptos)
|
||||
sinon.stub(remoteUpgrader, 'cryptos').value(cryptos)
|
||||
|
||||
// Remove the peer id from the remote address
|
||||
outbound.remoteAddr = outbound.remoteAddr.decapsulateCode(421)
|
||||
|
||||
const connections = await Promise.all([
|
||||
localUpgrader.upgradeOutbound(outbound),
|
||||
remoteUpgrader.upgradeInbound(inbound)
|
||||
])
|
||||
|
||||
expect(connections).to.have.length(2)
|
||||
})
|
||||
|
||||
it('should upgrade with valid muxers and crypto', async () => {
|
||||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })
|
||||
|
||||
|
Reference in New Issue
Block a user