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:
Alex Potsides 2021-12-08 08:38:17 +00:00 committed by GitHub
parent b539f9b655
commit 1b46f47fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 155 additions and 138 deletions

View File

@ -37,7 +37,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx aegir test -t node --cov --bail
- run: npm run test:node -- --cov --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
@ -48,7 +48,7 @@ jobs:
with:
node-version: lts/*
- run: npm install
- run: npx aegir test -t browser -t webworker --bail
- run: npm run test:browser -- -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
@ -58,7 +58,7 @@ jobs:
with:
node-version: lts/*
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
- run: npm run test:browser -- -t browser -t webworker --bail -- --browser firefox
test-ts:
needs: check
runs-on: ubuntu-latest

View File

@ -151,7 +151,7 @@
"libp2p": ".",
"libp2p-bootstrap": "^0.14.0",
"libp2p-delegated-content-routing": "^0.11.0",
"libp2p-delegated-peer-routing": "^0.11.0",
"libp2p-delegated-peer-routing": "^0.11.1",
"libp2p-floodsub": "^0.27.0",
"libp2p-gossipsub": "^0.12.1",
"libp2p-interfaces-compliance-tests": "^2.0.1",

View File

@ -4,7 +4,7 @@ const debug = require('debug')
const log = Object.assign(debug('libp2p:relay'), {
error: debug('libp2p:relay:err')
})
const { codes } = require('./../errors')
const {
setDelayedInterval,
clearDelayedInterval
@ -88,7 +88,7 @@ class Relay {
const cid = await namespaceToCid(RELAY_RENDEZVOUS_NS)
await this._libp2p.contentRouting.provide(cid)
} catch (/** @type {any} */ err) {
if (err.code === 'NO_ROUTERS_AVAILABLE') {
if (err.code === codes.ERR_NO_ROUTERS_AVAILABLE) {
log.error('a content router, such as a DHT, must be provided in order to advertise the relay service', err)
// Stop the advertise
this.stop()

View File

@ -60,13 +60,7 @@ const DefaultConfig = {
protocolPrefix: 'ipfs',
dht: {
enabled: false,
kBucketSize: 20,
randomWalk: {
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
queriesPerPeriod: 1,
interval: 300e3,
timeout: 10e3
}
kBucketSize: 20
},
nat: {
enabled: true,

View File

@ -54,7 +54,7 @@ class ContentRouting {
*/
async * findProviders (key, options = {}) {
if (!this.routers.length) {
throw errCode(new Error('No content this.routers available'), 'NO_ROUTERS_AVAILABLE')
throw errCode(new Error('No content this.routers available'), codes.ERR_NO_ROUTERS_AVAILABLE)
}
yield * pipe(
@ -77,7 +77,7 @@ class ContentRouting {
*/
async provide (key) {
if (!this.routers.length) {
throw errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE')
throw errCode(new Error('No content routers available'), codes.ERR_NO_ROUTERS_AVAILABLE)
}
await Promise.all(this.routers.map((router) => router.provide(key)))

View File

@ -27,8 +27,12 @@ class DHTPeerRouting {
*/
async findPeer (peerId, options = {}) {
for await (const event of this._dht.findPeer(peerId, options)) {
if (event.name === 'FINAL_PEER') {
return event.peer
if (event.name === 'PEER_RESPONSE') {
const peer = event.closer.find(peerData => peerData.id.equals(peerId))
if (peer) {
return peer
}
}
}

View File

@ -38,7 +38,7 @@ exports.codes = {
ERR_INVALID_MULTIADDR: 'ERR_INVALID_MULTIADDR',
ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID',
ERR_FIND_SELF: 'ERR_FIND_SELF',
ERR_NO_ROUTERS: 'ERR_NO_ROUTERS',
ERR_NO_ROUTERS_AVAILABLE: 'ERR_NO_ROUTERS_AVAILABLE',
ERR_CONNECTION_NOT_MULTIPLEXED: 'ERR_CONNECTION_NOT_MULTIPLEXED',
ERR_NO_DIAL_TOKENS: 'ERR_NO_DIAL_TOKENS',
ERR_KEYCHAIN_REQUIRED: 'ERR_KEYCHAIN_REQUIRED',

View File

@ -56,16 +56,9 @@ const { updateSelfPeerRecord } = require('./record/utils')
* @property {MuxedStream} stream
* @property {string} protocol
*
* @typedef {Object} RandomWalkOptions
* @property {boolean} [enabled = false]
* @property {number} [queriesPerPeriod = 1]
* @property {number} [interval = 300e3]
* @property {number} [timeout = 10e3]
*
* @typedef {Object} DhtOptions
* @property {boolean} [enabled = false]
* @property {number} [kBucketSize = 20]
* @property {RandomWalkOptions} [randomWalk]
* @property {boolean} [clientMode]
* @property {import('libp2p-interfaces/src/types').DhtSelectors} [selectors]
* @property {import('libp2p-interfaces/src/types').DhtValidators} [validators]

View File

@ -105,7 +105,7 @@ class PeerRouting {
*/
async findPeer (id, options) { // eslint-disable-line require-await
if (!this._routers.length) {
throw errCode(new Error('No peer routers available'), errors.codes.ERR_NO_ROUTERS)
throw errCode(new Error('No peer routers available'), errors.codes.ERR_NO_ROUTERS_AVAILABLE)
}
if (id.toB58String() === this._peerId.toB58String()) {
@ -145,7 +145,7 @@ class PeerRouting {
*/
async * getClosestPeers (key, options = { timeout: 30e3 }) {
if (!this._routers.length) {
throw errCode(new Error('No peer routers available'), errors.codes.ERR_NO_ROUTERS)
throw errCode(new Error('No peer routers available'), errors.codes.ERR_NO_ROUTERS_AVAILABLE)
}
if (options.timeout) {

View File

@ -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

View File

@ -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)
})
})

View File

@ -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)
})
})
})

View File

@ -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'
]

View File

@ -13,9 +13,6 @@ const routingOptions = mergeOptions(baseOptions, {
config: {
dht: {
kBucketSize: 20,
randomWalk: {
enabled: true
},
enabled: true
}
}

View File

@ -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 {

View File

@ -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))

View File

@ -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')
})

View File

@ -13,9 +13,6 @@ const routingOptions = mergeOptions(baseOptions, {
config: {
dht: {
kBucketSize: 20,
randomWalk: {
enabled: true
},
enabled: true
}
}

View File

@ -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()

View File

@ -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",

View File

@ -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