diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b0f4fa4b..86ce413215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- `Error: Bootstrap requires a list of peer addresses` error when using `bootstrap: true` in `Waku.create`. + ## [0.13.0] - 2021-09-16 ### Changed diff --git a/src/lib/discovery.ts b/src/lib/discovery.ts index 327bb236ee..b7be798778 100644 --- a/src/lib/discovery.ts +++ b/src/lib/discovery.ts @@ -61,7 +61,7 @@ export async function getBootstrapNodes( if (typeof nodes === 'object') { nodes = Object.values(nodes); - getPseudoRandomSubset(nodes, wantedNumber); + return getPseudoRandomSubset(nodes, wantedNumber); } throw `Failed to retrieve bootstrap nodes: response format is not supported: ${JSON.stringify( diff --git a/src/lib/waku.spec.ts b/src/lib/waku.spec.ts index 528d7649df..d822c8bae3 100644 --- a/src/lib/waku.spec.ts +++ b/src/lib/waku.spec.ts @@ -31,6 +31,25 @@ describe('Waku Dial', function () { }); describe('Bootstrap', function () { + it('Passing a boolean', async function () { + // This test depends on fleets.status.im being online. + // This dependence must be removed once DNS discovery is implemented + this.timeout(20_000); + + waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + bootstrap: true, + }); + + const connectedPeerID: PeerId = await new Promise((resolve) => { + waku.libp2p.connectionManager.on('peer:connect', (connection) => { + resolve(connection.remotePeer); + }); + }); + + expect(connectedPeerID).to.not.be.undefined; + }); + it('Passing an array', async function () { this.timeout(10_000); diff --git a/src/lib/waku.ts b/src/lib/waku.ts index 55833a6350..286cd3487e 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -202,14 +202,14 @@ export class Waku { } if (bootstrap !== undefined) { - // Note: this overrides any other peer discover - libp2pOpts.modules = Object.assign(libp2pOpts.modules, { - peerDiscovery: [Bootstrap], - }); - try { const list = await bootstrap(); + // Note: this overrides any other peer discover + libp2pOpts.modules = Object.assign(libp2pOpts.modules, { + peerDiscovery: [Bootstrap], + }); + libp2pOpts.config.peerDiscovery = { [Bootstrap.tag]: { list,