Skip to content

Commit

Permalink
fix(test): improve flakey random walk discovery test (#574)
Browse files Browse the repository at this point in the history
* test: improve stability of dht discovery test

* test: isolate who is random walking
  • Loading branch information
jacobheun authored Feb 28, 2020
1 parent 524e6f8 commit f4ec355
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/peer-discovery/index.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,21 @@ describe('peer discovery scenarios', () => {
},
dht: {
randomWalk: {
enabled: true,
enabled: false,
delay: 1000, // start the first query quickly
interval: 10000,
timeout: 1000
timeout: 5000
},
enabled: true
}
}
})

libp2p = new Libp2p(getConfig(peerInfo))
const localConfig = getConfig(peerInfo)
// Only run random walk on our local node
localConfig.config.dht.randomWalk.enabled = true
libp2p = new Libp2p(localConfig)

const remoteLibp2p1 = new Libp2p(getConfig(remotePeerInfo1))
const remoteLibp2p2 = new Libp2p(getConfig(remotePeerInfo2))

Expand All @@ -161,6 +165,7 @@ describe('peer discovery scenarios', () => {
})

await Promise.all([
libp2p.start(),
remoteLibp2p1.start(),
remoteLibp2p2.start()
])
Expand All @@ -173,8 +178,6 @@ describe('peer discovery scenarios', () => {
remoteLibp2p2.dial(remotePeerInfo1)
])

libp2p.start()

await deferred.promise
return Promise.all([
remoteLibp2p1.stop(),
Expand Down

0 comments on commit f4ec355

Please sign in to comment.