Skip to content

Commit d432f08

Browse files
authored
Merge pull request #298 from status-im/boostrap-true
2 parents eef6ff8 + 6b11bc7 commit d432f08

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- `Error: Bootstrap requires a list of peer addresses` error when using `bootstrap: true` in `Waku.create`.
13+
1014
## [0.13.0] - 2021-09-16
1115

1216
### Changed

src/lib/discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export async function getBootstrapNodes(
6161

6262
if (typeof nodes === 'object') {
6363
nodes = Object.values(nodes);
64-
getPseudoRandomSubset(nodes, wantedNumber);
64+
return getPseudoRandomSubset(nodes, wantedNumber);
6565
}
6666

6767
throw `Failed to retrieve bootstrap nodes: response format is not supported: ${JSON.stringify(

src/lib/waku.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ describe('Waku Dial', function () {
3131
});
3232

3333
describe('Bootstrap', function () {
34+
it('Passing a boolean', async function () {
35+
// This test depends on fleets.status.im being online.
36+
// This dependence must be removed once DNS discovery is implemented
37+
this.timeout(20_000);
38+
39+
waku = await Waku.create({
40+
staticNoiseKey: NOISE_KEY_1,
41+
bootstrap: true,
42+
});
43+
44+
const connectedPeerID: PeerId = await new Promise((resolve) => {
45+
waku.libp2p.connectionManager.on('peer:connect', (connection) => {
46+
resolve(connection.remotePeer);
47+
});
48+
});
49+
50+
expect(connectedPeerID).to.not.be.undefined;
51+
});
52+
3453
it('Passing an array', async function () {
3554
this.timeout(10_000);
3655

src/lib/waku.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ export class Waku {
202202
}
203203

204204
if (bootstrap !== undefined) {
205-
// Note: this overrides any other peer discover
206-
libp2pOpts.modules = Object.assign(libp2pOpts.modules, {
207-
peerDiscovery: [Bootstrap],
208-
});
209-
210205
try {
211206
const list = await bootstrap();
212207

208+
// Note: this overrides any other peer discover
209+
libp2pOpts.modules = Object.assign(libp2pOpts.modules, {
210+
peerDiscovery: [Bootstrap],
211+
});
212+
213213
libp2pOpts.config.peerDiscovery = {
214214
[Bootstrap.tag]: {
215215
list,

0 commit comments

Comments
 (0)