Merge pull request #298 from status-im/boostrap-true

This commit is contained in:
Franck Royer 2021-09-21 14:55:37 +10:00 committed by GitHub
commit d432f08652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 6 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- `Error: Bootstrap requires a list of peer addresses` error when using `bootstrap: true` in `Waku.create`.
## [0.13.0] - 2021-09-16 ## [0.13.0] - 2021-09-16
### Changed ### Changed

View File

@ -61,7 +61,7 @@ export async function getBootstrapNodes(
if (typeof nodes === 'object') { if (typeof nodes === 'object') {
nodes = Object.values(nodes); nodes = Object.values(nodes);
getPseudoRandomSubset(nodes, wantedNumber); return getPseudoRandomSubset(nodes, wantedNumber);
} }
throw `Failed to retrieve bootstrap nodes: response format is not supported: ${JSON.stringify( throw `Failed to retrieve bootstrap nodes: response format is not supported: ${JSON.stringify(

View File

@ -31,6 +31,25 @@ describe('Waku Dial', function () {
}); });
describe('Bootstrap', 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 () { it('Passing an array', async function () {
this.timeout(10_000); this.timeout(10_000);

View File

@ -202,14 +202,14 @@ export class Waku {
} }
if (bootstrap !== undefined) { if (bootstrap !== undefined) {
try {
const list = await bootstrap();
// Note: this overrides any other peer discover // Note: this overrides any other peer discover
libp2pOpts.modules = Object.assign(libp2pOpts.modules, { libp2pOpts.modules = Object.assign(libp2pOpts.modules, {
peerDiscovery: [Bootstrap], peerDiscovery: [Bootstrap],
}); });
try {
const list = await bootstrap();
libp2pOpts.config.peerDiscovery = { libp2pOpts.config.peerDiscovery = {
[Bootstrap.tag]: { [Bootstrap.tag]: {
list, list,