Skip to content

Commit f4ec355

Browse files
authored
fix(test): improve flakey random walk discovery test (#574)
* test: improve stability of dht discovery test * test: isolate who is random walking
1 parent 524e6f8 commit f4ec355

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/peer-discovery/index.node.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,21 @@ describe('peer discovery scenarios', () => {
139139
},
140140
dht: {
141141
randomWalk: {
142-
enabled: true,
142+
enabled: false,
143143
delay: 1000, // start the first query quickly
144144
interval: 10000,
145-
timeout: 1000
145+
timeout: 5000
146146
},
147147
enabled: true
148148
}
149149
}
150150
})
151151

152-
libp2p = new Libp2p(getConfig(peerInfo))
152+
const localConfig = getConfig(peerInfo)
153+
// Only run random walk on our local node
154+
localConfig.config.dht.randomWalk.enabled = true
155+
libp2p = new Libp2p(localConfig)
156+
153157
const remoteLibp2p1 = new Libp2p(getConfig(remotePeerInfo1))
154158
const remoteLibp2p2 = new Libp2p(getConfig(remotePeerInfo2))
155159

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

163167
await Promise.all([
168+
libp2p.start(),
164169
remoteLibp2p1.start(),
165170
remoteLibp2p2.start()
166171
])
@@ -173,8 +178,6 @@ describe('peer discovery scenarios', () => {
173178
remoteLibp2p2.dial(remotePeerInfo1)
174179
])
175180

176-
libp2p.start()
177-
178181
await deferred.promise
179182
return Promise.all([
180183
remoteLibp2p1.stop(),

0 commit comments

Comments
 (0)