mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-12 16:51:23 +00:00
chore: run node tests in ci (#1057)
Looks like this project stopped running the `test:node` npm script when it was migrated to gh actions. Re-enable it and fix all the related test failures.
This commit is contained in:
@ -36,14 +36,14 @@ describe('content-routing', () => {
|
||||
throw new Error('.findProviders should return an error')
|
||||
} catch (/** @type {any} */ err) {
|
||||
expect(err).to.exist()
|
||||
expect(err.code).to.equal('NO_ROUTERS_AVAILABLE')
|
||||
expect(err.code).to.equal('ERR_NO_ROUTERS_AVAILABLE')
|
||||
}
|
||||
})
|
||||
|
||||
it('.provide should return an error', async () => {
|
||||
await expect(node.contentRouting.provide('a cid'))
|
||||
.to.eventually.be.rejected()
|
||||
.and.to.have.property('code', 'NO_ROUTERS_AVAILABLE')
|
||||
.and.to.have.property('code', 'ERR_NO_ROUTERS_AVAILABLE')
|
||||
})
|
||||
})
|
||||
|
||||
@ -87,8 +87,11 @@ describe('content-routing', () => {
|
||||
sinon.stub(nodes[0]._dht, 'findProviders').callsFake(function * () {
|
||||
deferred.resolve()
|
||||
yield {
|
||||
id: providerPeerId,
|
||||
multiaddrs: []
|
||||
name: 'PROVIDER',
|
||||
providers: [{
|
||||
id: providerPeerId,
|
||||
multiaddrs: []
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
@ -361,7 +364,12 @@ describe('content-routing', () => {
|
||||
}
|
||||
|
||||
sinon.stub(node._dht, 'findProviders').callsFake(async function * () {
|
||||
yield result1
|
||||
yield {
|
||||
name: 'PROVIDER',
|
||||
providers: [
|
||||
result1
|
||||
]
|
||||
}
|
||||
})
|
||||
sinon.stub(delegate, 'findProviders').callsFake(async function * () {
|
||||
yield result2
|
||||
@ -382,7 +390,8 @@ describe('content-routing', () => {
|
||||
const dhtDeferred = pDefer()
|
||||
const delegatedDeferred = pDefer()
|
||||
|
||||
sinon.stub(node._dht, 'provide').callsFake(() => {
|
||||
sinon.stub(node._dht, 'provide').callsFake(async function * () {
|
||||
yield
|
||||
dhtDeferred.resolve()
|
||||
})
|
||||
|
||||
@ -406,7 +415,12 @@ describe('content-routing', () => {
|
||||
}]
|
||||
|
||||
sinon.stub(node._dht, 'findProviders').callsFake(function * () {
|
||||
yield results[0]
|
||||
yield {
|
||||
name: 'PROVIDER',
|
||||
providers: [
|
||||
results[0]
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
sinon.stub(delegate, 'findProviders').callsFake(function * () { // eslint-disable-line require-yield
|
||||
|
@ -38,13 +38,13 @@ describe('DHT subsystem is configurable', () => {
|
||||
})
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(true)
|
||||
expect(libp2p._dht.isStarted()).to.equal(true)
|
||||
|
||||
await libp2p.stop()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
})
|
||||
|
||||
it('should not start if disabled once libp2p starts', async () => {
|
||||
@ -63,10 +63,10 @@ describe('DHT subsystem is configurable', () => {
|
||||
})
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
})
|
||||
|
||||
it('should allow a manual start', async () => {
|
||||
@ -86,9 +86,9 @@ describe('DHT subsystem is configurable', () => {
|
||||
|
||||
libp2p = await create(customOptions)
|
||||
await libp2p.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(false)
|
||||
expect(libp2p._dht.isStarted()).to.equal(false)
|
||||
|
||||
await libp2p._dht.start()
|
||||
expect(libp2p._dht.isStarted).to.equal(true)
|
||||
expect(libp2p._dht.isStarted()).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
@ -60,8 +60,8 @@ describe('DHT subsystem operates correctly', () => {
|
||||
expect(connection).to.exist()
|
||||
|
||||
return Promise.all([
|
||||
pWaitFor(() => libp2p._dht.routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht.routingTable.size === 1)
|
||||
pWaitFor(() => libp2p._dht._lan._routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht._lan._routingTable.size === 1)
|
||||
])
|
||||
})
|
||||
|
||||
@ -71,14 +71,14 @@ describe('DHT subsystem operates correctly', () => {
|
||||
|
||||
await libp2p.dialProtocol(remAddr, subsystemMulticodecs)
|
||||
await Promise.all([
|
||||
pWaitFor(() => libp2p._dht.routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht.routingTable.size === 1)
|
||||
pWaitFor(() => libp2p._dht._lan._routingTable.size === 1),
|
||||
pWaitFor(() => remoteLibp2p._dht._lan._routingTable.size === 1)
|
||||
])
|
||||
|
||||
await libp2p.contentRouting.put(key, value)
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
|
||||
expect(fetchedValue).to.eql(value)
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
expect(fetchedValue).to.have.property('val').that.equalBytes(value)
|
||||
})
|
||||
})
|
||||
|
||||
@ -119,11 +119,13 @@ describe('DHT subsystem operates correctly', () => {
|
||||
const connection = await libp2p.dial(remAddr)
|
||||
|
||||
expect(connection).to.exist()
|
||||
expect(libp2p._dht.routingTable.size).to.be.eql(0)
|
||||
expect(remoteLibp2p._dht.routingTable.size).to.be.eql(0)
|
||||
expect(libp2p._dht._lan._routingTable.size).to.be.eql(0)
|
||||
|
||||
await remoteLibp2p._dht.start()
|
||||
return pWaitFor(() => libp2p._dht.routingTable.size === 1)
|
||||
// should be 0 directly after start - TODO this may be susceptible to timing bugs, we should have
|
||||
// the ability to report stats on the DHT routing table instead of reaching into it's heart like this
|
||||
expect(remoteLibp2p._dht._lan._routingTable.size).to.be.eql(0)
|
||||
return pWaitFor(() => libp2p._dht._lan._routingTable.size === 1)
|
||||
})
|
||||
|
||||
it('should put on a peer and get from the other', async () => {
|
||||
@ -133,12 +135,12 @@ describe('DHT subsystem operates correctly', () => {
|
||||
const value = uint8ArrayFromString('world')
|
||||
|
||||
await remoteLibp2p._dht.start()
|
||||
await pWaitFor(() => libp2p._dht.routingTable.size === 1)
|
||||
await pWaitFor(() => libp2p._dht._lan._routingTable.size === 1)
|
||||
|
||||
await libp2p.contentRouting.put(key, value)
|
||||
|
||||
const fetchedValue = await remoteLibp2p.contentRouting.get(key)
|
||||
expect(fetchedValue).to.eql(value)
|
||||
expect(fetchedValue).to.have.property('val').that.equalBytes(value)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,7 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const KadDht = require('libp2p-kad-dht')
|
||||
const { multicodec } = require('libp2p-kad-dht')
|
||||
const Crypto = require('../../../src/insecure/plaintext')
|
||||
const Muxer = require('libp2p-mplex')
|
||||
const Transport = require('libp2p-tcp')
|
||||
@ -25,13 +24,12 @@ const subsystemOptions = mergeOptions(baseOptions, {
|
||||
config: {
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: true
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports.subsystemOptions = subsystemOptions
|
||||
module.exports.subsystemMulticodecs = [multicodec]
|
||||
module.exports.subsystemMulticodecs = [
|
||||
'/ipfs/lan/kad/1.0.0'
|
||||
]
|
||||
|
@ -13,9 +13,6 @@ const routingOptions = mergeOptions(baseOptions, {
|
||||
config: {
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: true
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +244,10 @@ describe('Nat Manager (TCP)', () => {
|
||||
})
|
||||
|
||||
it('shuts the nat api down when stopping', async function () {
|
||||
if (process.env.CI) {
|
||||
return this.skip('CI environments will not let us map external ports')
|
||||
}
|
||||
|
||||
function findRoutableAddress () {
|
||||
const interfaces = networkInterfaces()
|
||||
|
||||
@ -261,7 +265,7 @@ describe('Nat Manager (TCP)', () => {
|
||||
|
||||
if (!addr) {
|
||||
// skip test if no non-loopback address is found
|
||||
this.skip()
|
||||
return this.skip()
|
||||
}
|
||||
|
||||
const {
|
||||
|
@ -161,20 +161,13 @@ describe('peer discovery scenarios', () => {
|
||||
autoDial: false
|
||||
},
|
||||
dht: {
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
delay: 1000, // start the first query quickly
|
||||
interval: 10000,
|
||||
timeout: 5000
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const localConfig = getConfig(peerId)
|
||||
// Only run random walk on our local node
|
||||
localConfig.config.dht.randomWalk.enabled = true
|
||||
|
||||
libp2p = new Libp2p(localConfig)
|
||||
|
||||
const remoteLibp2p1 = new Libp2p(getConfig(remotePeerId1))
|
||||
|
@ -36,7 +36,7 @@ describe('peer-routing', () => {
|
||||
it('.findPeer should return an error', async () => {
|
||||
await expect(node.peerRouting.findPeer('a cid'))
|
||||
.to.eventually.be.rejected()
|
||||
.and.to.have.property('code', 'NO_ROUTERS_AVAILABLE')
|
||||
.and.to.have.property('code', 'ERR_NO_ROUTERS_AVAILABLE')
|
||||
})
|
||||
|
||||
it('.getClosestPeers should return an error', async () => {
|
||||
@ -45,7 +45,7 @@ describe('peer-routing', () => {
|
||||
throw new Error('.getClosestPeers should return an error')
|
||||
} catch (/** @type {any} */ err) {
|
||||
expect(err).to.exist()
|
||||
expect(err.code).to.equal('NO_ROUTERS_AVAILABLE')
|
||||
expect(err.code).to.equal('ERR_NO_ROUTERS_AVAILABLE')
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -72,33 +72,38 @@ describe('peer-routing', () => {
|
||||
|
||||
after(() => Promise.all(nodes.map((n) => n.stop())))
|
||||
|
||||
it('should use the nodes dht', () => {
|
||||
const deferred = pDefer()
|
||||
|
||||
sinon.stub(nodes[0]._dht, 'findPeer').callsFake(() => {
|
||||
deferred.resolve()
|
||||
return nodes[1].peerId
|
||||
})
|
||||
|
||||
nodes[0].peerRouting.findPeer()
|
||||
return deferred.promise
|
||||
})
|
||||
|
||||
it('should use the nodes dht to get the closest peers', async () => {
|
||||
const deferred = pDefer()
|
||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||
|
||||
sinon.stub(nodes[0]._dht, 'getClosestPeers').callsFake(function * () {
|
||||
deferred.resolve()
|
||||
it('should use the nodes dht', async () => {
|
||||
sinon.stub(nodes[0]._dht, 'findPeer').callsFake(async function * () {
|
||||
yield {
|
||||
id: remotePeerId,
|
||||
multiaddrs: []
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [{
|
||||
id: nodes[1].peerId,
|
||||
multiaddrs: []
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
await nodes[0].peerRouting.getClosestPeers().next()
|
||||
expect(nodes[0]._dht.findPeer.called).to.be.false()
|
||||
await nodes[0].peerRouting.findPeer(nodes[1].peerId)
|
||||
expect(nodes[0]._dht.findPeer.called).to.be.true()
|
||||
nodes[0]._dht.findPeer.restore()
|
||||
})
|
||||
|
||||
return deferred.promise
|
||||
it('should use the nodes dht to get the closest peers', async () => {
|
||||
sinon.stub(nodes[0]._dht, 'getClosestPeers').callsFake(async function * () {
|
||||
yield {
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [{
|
||||
id: nodes[1].peerId,
|
||||
multiaddrs: []
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
expect(nodes[0]._dht.getClosestPeers.called).to.be.false()
|
||||
await drain(nodes[0].peerRouting.getClosestPeers(nodes[1].peerId))
|
||||
expect(nodes[0]._dht.getClosestPeers.called).to.be.true()
|
||||
nodes[0]._dht.getClosestPeers.restore()
|
||||
})
|
||||
|
||||
it('should error when peer tries to find itself', async () => {
|
||||
@ -234,36 +239,35 @@ describe('peer-routing', () => {
|
||||
})
|
||||
|
||||
it('should use the delegate router to find peers', async () => {
|
||||
const deferred = pDefer()
|
||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||
|
||||
sinon.stub(delegate, 'findPeer').callsFake(() => {
|
||||
deferred.resolve()
|
||||
return {
|
||||
id: remotePeerId,
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
|
||||
await node.peerRouting.findPeer()
|
||||
return deferred.promise
|
||||
expect(delegate.findPeer.called).to.be.false()
|
||||
await node.peerRouting.findPeer(remotePeerId)
|
||||
expect(delegate.findPeer.called).to.be.true()
|
||||
delegate.findPeer.restore()
|
||||
})
|
||||
|
||||
it('should use the delegate router to get the closest peers', async () => {
|
||||
const deferred = pDefer()
|
||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||
|
||||
sinon.stub(delegate, 'getClosestPeers').callsFake(function * () {
|
||||
deferred.resolve()
|
||||
yield {
|
||||
id: remotePeerId,
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
|
||||
await node.peerRouting.getClosestPeers().next()
|
||||
|
||||
return deferred.promise
|
||||
expect(delegate.getClosestPeers.called).to.be.false()
|
||||
await drain(node.peerRouting.getClosestPeers(remotePeerId))
|
||||
expect(delegate.getClosestPeers.called).to.be.true()
|
||||
delegate.getClosestPeers.restore()
|
||||
})
|
||||
|
||||
it('should be able to find a peer', async () => {
|
||||
@ -289,7 +293,7 @@ describe('peer-routing', () => {
|
||||
})
|
||||
|
||||
it('should error when a peer cannot be found', async () => {
|
||||
const peerKey = 'key of a peer not on the network'
|
||||
const peerId = await PeerId.create({ keyType: 'ed25519' })
|
||||
const mockApi = nock('http://0.0.0.0:60197')
|
||||
.post('/api/v0/dht/findpeer')
|
||||
.query(true)
|
||||
@ -298,20 +302,20 @@ describe('peer-routing', () => {
|
||||
'X-Chunked-Output', '1'
|
||||
])
|
||||
|
||||
await expect(node.peerRouting.findPeer(peerKey))
|
||||
await expect(node.peerRouting.findPeer(peerId))
|
||||
.to.eventually.be.rejected()
|
||||
|
||||
expect(mockApi.isDone()).to.equal(true)
|
||||
})
|
||||
|
||||
it('should handle errors from the api', async () => {
|
||||
const peerKey = 'key of a peer not on the network'
|
||||
const peerId = await PeerId.create({ keyType: 'ed25519' })
|
||||
const mockApi = nock('http://0.0.0.0:60197')
|
||||
.post('/api/v0/dht/findpeer')
|
||||
.query(true)
|
||||
.reply(502)
|
||||
|
||||
await expect(node.peerRouting.findPeer(peerKey))
|
||||
await expect(node.peerRouting.findPeer(peerId))
|
||||
.to.eventually.be.rejected()
|
||||
|
||||
expect(mockApi.isDone()).to.equal(true)
|
||||
@ -319,7 +323,6 @@ describe('peer-routing', () => {
|
||||
|
||||
it('should be able to get the closest peers', async () => {
|
||||
const peerId = await PeerId.create({ keyType: 'ed25519' })
|
||||
|
||||
const closest1 = '12D3KooWLewYMMdGWAtuX852n4rgCWkK7EBn4CWbwwBzhsVoKxk3'
|
||||
const closest2 = '12D3KooWDtoQbpKhtnWddfj72QmpFvvLDTsBLTFkjvgQm6cde2AK'
|
||||
|
||||
@ -338,15 +341,12 @@ describe('peer-routing', () => {
|
||||
'X-Chunked-Output', '1'
|
||||
])
|
||||
|
||||
const closestPeers = []
|
||||
for await (const peer of node.peerRouting.getClosestPeers(peerId.id, { timeout: 1000 })) {
|
||||
closestPeers.push(peer)
|
||||
}
|
||||
const closestPeers = await all(node.peerRouting.getClosestPeers(peerId.id, { timeout: 1000 }))
|
||||
|
||||
expect(closestPeers).to.have.length(2)
|
||||
expect(closestPeers[0].id.toB58String()).to.equal(closest2)
|
||||
expect(closestPeers[0].id.toB58String()).to.equal(closest1)
|
||||
expect(closestPeers[0].multiaddrs).to.have.lengthOf(2)
|
||||
expect(closestPeers[1].id.toB58String()).to.equal(closest1)
|
||||
expect(closestPeers[1].id.toB58String()).to.equal(closest2)
|
||||
expect(closestPeers[1].multiaddrs).to.have.lengthOf(2)
|
||||
expect(mockApi.isDone()).to.equal(true)
|
||||
})
|
||||
@ -405,7 +405,7 @@ describe('peer-routing', () => {
|
||||
multiaddrs: []
|
||||
}
|
||||
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(() => {})
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(async function * () {})
|
||||
sinon.stub(delegate, 'findPeer').callsFake(() => {
|
||||
return results
|
||||
})
|
||||
@ -423,7 +423,8 @@ describe('peer-routing', () => {
|
||||
|
||||
const defer = pDefer()
|
||||
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(async () => {
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(async function * () {
|
||||
yield
|
||||
await defer.promise
|
||||
})
|
||||
sinon.stub(delegate, 'findPeer').callsFake(() => {
|
||||
@ -438,29 +439,34 @@ describe('peer-routing', () => {
|
||||
|
||||
it('should not wait for the delegate to return if the dht does first', async () => {
|
||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||
const results = {
|
||||
const result = {
|
||||
id: remotePeerId,
|
||||
multiaddrs: []
|
||||
}
|
||||
|
||||
const defer = pDefer()
|
||||
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(() => {
|
||||
return results
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(async function * () {
|
||||
yield {
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [
|
||||
result
|
||||
]
|
||||
}
|
||||
})
|
||||
sinon.stub(delegate, 'findPeer').callsFake(async () => {
|
||||
await defer.promise
|
||||
})
|
||||
|
||||
const peer = await node.peerRouting.findPeer(remotePeerId)
|
||||
expect(peer).to.eql(results)
|
||||
expect(peer).to.eql(result)
|
||||
|
||||
defer.resolve()
|
||||
})
|
||||
|
||||
it('should store the addresses of the found peer', async () => {
|
||||
const [remotePeerId] = await peerUtils.createPeerId({ fixture: false })
|
||||
const results = {
|
||||
const result = {
|
||||
id: remotePeerId,
|
||||
multiaddrs: [
|
||||
new Multiaddr('/ip4/123.123.123.123/tcp/38982')
|
||||
@ -469,14 +475,19 @@ describe('peer-routing', () => {
|
||||
|
||||
const spy = sinon.spy(node.peerStore.addressBook, 'add')
|
||||
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(() => {
|
||||
return results
|
||||
sinon.stub(node._dht, 'findPeer').callsFake(async function * () {
|
||||
yield {
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [
|
||||
result
|
||||
]
|
||||
}
|
||||
})
|
||||
sinon.stub(delegate, 'findPeer').callsFake(() => {})
|
||||
|
||||
await node.peerRouting.findPeer(remotePeerId)
|
||||
|
||||
expect(spy.calledWith(results.id, results.multiaddrs)).to.be.true()
|
||||
expect(spy.calledWith(result.id, result.multiaddrs)).to.be.true()
|
||||
})
|
||||
|
||||
it('should use the delegate if the dht fails to get the closest peer', async () => {
|
||||
@ -576,8 +587,18 @@ describe('peer-routing', () => {
|
||||
|
||||
sinon.spy(node.peerStore.addressBook, 'add')
|
||||
sinon.stub(node._dht, 'getClosestPeers').callsFake(function * () {
|
||||
yield results[0]
|
||||
yield results[1]
|
||||
yield {
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [
|
||||
results[0]
|
||||
]
|
||||
}
|
||||
yield {
|
||||
name: 'PEER_RESPONSE',
|
||||
closer: [
|
||||
results[1]
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
await node.start()
|
||||
@ -611,7 +632,7 @@ describe('peer-routing', () => {
|
||||
started: false
|
||||
})
|
||||
|
||||
sinon.stub(node._dht, 'getClosestPeers').callsFake(function * () {
|
||||
sinon.stub(node._dht, 'getClosestPeers').callsFake(async function * () {
|
||||
yield
|
||||
throw new Error('should not be called')
|
||||
})
|
||||
|
@ -13,9 +13,6 @@ const routingOptions = mergeOptions(baseOptions, {
|
||||
config: {
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: true
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ const { Multiaddr } = require('multiaddr')
|
||||
const mockUpgrader = require('../utils/mockUpgrader')
|
||||
const sinon = require('sinon')
|
||||
const Peers = require('../fixtures/peers')
|
||||
const pWaitFor = require('p-wait-for')
|
||||
const addrs = [
|
||||
new Multiaddr('/ip4/127.0.0.1/tcp/0'),
|
||||
new Multiaddr('/ip4/127.0.0.1/tcp/0')
|
||||
@ -72,9 +73,13 @@ describe('Transport Manager (TCP)', () => {
|
||||
tm.add(Transport.prototype[Symbol.toStringTag], Transport)
|
||||
await tm.listen(addrs)
|
||||
|
||||
// Should created Self Peer record on new listen address
|
||||
signedPeerRecord = await tm.libp2p.peerStore.addressBook.getPeerRecord(localPeer)
|
||||
expect(signedPeerRecord).to.exist()
|
||||
// Should created Self Peer record on new listen address, but it is done async
|
||||
// with no event so we have to wait a bit
|
||||
await pWaitFor(async () => {
|
||||
signedPeerRecord = await tm.libp2p.peerStore.addressBook.getPeerRecord(localPeer)
|
||||
|
||||
return signedPeerRecord != null
|
||||
}, { interval: 100, timeout: 2000 })
|
||||
|
||||
const record = PeerRecord.createFromProtobuf(signedPeerRecord.payload)
|
||||
expect(record).to.exist()
|
||||
|
@ -7,7 +7,7 @@
|
||||
"libp2p": "file:../..",
|
||||
"libp2p-bootstrap": "^0.13.0",
|
||||
"libp2p-delegated-content-routing": "^0.11.0",
|
||||
"libp2p-delegated-peer-routing": "^0.10.0",
|
||||
"libp2p-delegated-peer-routing": "^0.11.1",
|
||||
"libp2p-gossipsub": "^0.9.0",
|
||||
"libp2p-interfaces": "^1.0.1",
|
||||
"libp2p-kad-dht": "^0.26.5",
|
||||
|
@ -123,11 +123,6 @@ async function main() {
|
||||
dht: {
|
||||
enabled: true,
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: true, // Allows to disable discovery (enabled by default)
|
||||
interval: 300e3,
|
||||
timeout: 10e3
|
||||
},
|
||||
clientMode: true,
|
||||
validators: {
|
||||
pk: Libp2pRecord.validator.validators.pk
|
||||
|
Reference in New Issue
Block a user