mirror of https://github.com/status-im/js-waku.git
Upgrade nim-waku to v0.7 (#417)
This commit is contained in:
parent
8a0ccd123b
commit
cba5212872
|
@ -12,7 +12,7 @@ jobs:
|
|||
build_and_test:
|
||||
env:
|
||||
BUF_VERSION: '0.56.0'
|
||||
NIM_WAKU_VERSION: 'v0.6'
|
||||
NIM_WAKU_VERSION: 'v0.7'
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
|
@ -27,8 +27,7 @@ jobs:
|
|||
run: |
|
||||
mkdir -p nim-waku/build
|
||||
cd nim-waku
|
||||
wget "https://github.com/status-im/nim-waku/releases/download/${NIM_WAKU_VERSION}/nim-waku-ubuntu-latest.tar.gz.1.zip"
|
||||
unzip nim-waku-ubuntu-latest.tar.gz.1.zip
|
||||
wget "https://github.com/status-im/nim-waku/releases/download/${NIM_WAKU_VERSION}/nim-waku-ubuntu-latest.tar.gz"
|
||||
tar xavf nim-waku-ubuntu-latest.tar.gz
|
||||
|
||||
- name: Install NodeJS
|
||||
|
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Test: Upgrade nim-waku node to v0.7.
|
||||
|
||||
## [0.15.0] - 2022-01-17
|
||||
|
||||
### Added
|
||||
|
|
2
nim-waku
2
nim-waku
|
@ -1 +1 @@
|
|||
Subproject commit ea14823dafcbabd4ac5457b3f1311f2ed62a2d68
|
||||
Subproject commit dba82b6c9c9a8982608f52955356a2df8efcaf9e
|
|
@ -309,8 +309,12 @@ export class Waku {
|
|||
* with [[Waku.create]]. The Promise resolves only once we are connected to a
|
||||
* Store peer, Relay peer and Light Push peer.
|
||||
*/
|
||||
async waitForConnectedPeer(): Promise<void> {
|
||||
const desiredProtocols = [[StoreCodec], [LightPushCodec], RelayCodecs];
|
||||
async waitForConnectedPeer(protocols?: string[][]): Promise<void> {
|
||||
const desiredProtocols = protocols ?? [
|
||||
[StoreCodec],
|
||||
[LightPushCodec],
|
||||
RelayCodecs,
|
||||
];
|
||||
|
||||
await Promise.all(
|
||||
desiredProtocols.map((desiredProtocolVersions) => {
|
||||
|
|
|
@ -30,11 +30,7 @@ describe('Waku Light Push [node only]', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer();
|
||||
|
||||
const messageText = 'Light Push works!';
|
||||
const message = await WakuMessage.fromUtf8String(
|
||||
|
@ -71,11 +67,7 @@ describe('Waku Light Push [node only]', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer();
|
||||
|
||||
const nimPeerId = await nimWaku.getPeerId();
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ import {
|
|||
getPublicKey,
|
||||
} from '../waku_message/version_1';
|
||||
|
||||
import { RelayCodecs } from './constants';
|
||||
|
||||
const log = debug('waku:test');
|
||||
|
||||
const TestContentTopic = '/test/1/waku-relay/utf8';
|
||||
|
@ -427,11 +429,7 @@ describe('Waku Relay [node only]', () => {
|
|||
await nimWaku.start();
|
||||
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([RelayCodecs]);
|
||||
|
||||
// Wait for one heartbeat to ensure mesh is updated
|
||||
await new Promise((resolve) => {
|
||||
|
@ -542,12 +540,8 @@ describe('Waku Relay [node only]', () => {
|
|||
|
||||
// Wait for identify protocol to finish
|
||||
await Promise.all([
|
||||
new Promise((resolve) =>
|
||||
waku1.libp2p.peerStore.once('change:protocols', resolve)
|
||||
),
|
||||
new Promise((resolve) =>
|
||||
waku2.libp2p.peerStore.once('change:protocols', resolve)
|
||||
),
|
||||
waku1.waitForConnectedPeer([RelayCodecs]),
|
||||
waku2.waitForConnectedPeer([RelayCodecs]),
|
||||
]);
|
||||
|
||||
await Promise.all([
|
||||
|
|
|
@ -21,6 +21,8 @@ import {
|
|||
|
||||
import { PageDirection } from './history_rpc';
|
||||
|
||||
import { StoreCodec } from './index';
|
||||
|
||||
const dbg = debug('waku:test:store');
|
||||
|
||||
const TestContentTopic = '/test/1/waku-store/utf8';
|
||||
|
@ -53,12 +55,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
const messages = await waku.store.queryHistory([]);
|
||||
|
||||
expect(messages?.length).eq(2);
|
||||
|
@ -89,11 +86,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
|
||||
let messages: WakuMessage[] = [];
|
||||
|
||||
|
@ -131,11 +124,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
|
||||
let messages: WakuMessage[] = [];
|
||||
const desiredMsgs = 14;
|
||||
|
@ -170,11 +159,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
|
||||
const messages = await waku.store.queryHistory([], {
|
||||
pageDirection: PageDirection.FORWARD,
|
||||
|
@ -212,11 +197,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
|
||||
const nimPeerId = await nimWaku.getPeerId();
|
||||
|
||||
|
@ -485,11 +466,7 @@ describe('Waku Store', () => {
|
|||
libp2p: { modules: { transport: [TCP] } },
|
||||
});
|
||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||
|
||||
// Wait for identify protocol to finish
|
||||
await new Promise((resolve) => {
|
||||
waku.libp2p.peerStore.once('change:protocols', resolve);
|
||||
});
|
||||
await waku.waitForConnectedPeer([[StoreCodec]]);
|
||||
|
||||
const nimPeerId = await nimWaku.getPeerId();
|
||||
|
||||
|
|
|
@ -303,14 +303,14 @@ export class NimWaku {
|
|||
}
|
||||
|
||||
async getPeerId(): Promise<PeerId> {
|
||||
return await this.setPeerId().then((res) => res.peerId);
|
||||
return await this._getPeerId().then((res) => res.peerId);
|
||||
}
|
||||
|
||||
async getMultiaddrWithId(): Promise<Multiaddr> {
|
||||
return await this.setPeerId().then((res) => res.multiaddrWithId);
|
||||
return await this._getPeerId().then((res) => res.multiaddrWithId);
|
||||
}
|
||||
|
||||
private async setPeerId(): Promise<{
|
||||
private async _getPeerId(): Promise<{
|
||||
peerId: PeerId;
|
||||
multiaddrWithId: Multiaddr;
|
||||
}> {
|
||||
|
@ -318,7 +318,8 @@ export class NimWaku {
|
|||
return { peerId: this.peerId, multiaddrWithId: this.multiaddrWithId };
|
||||
}
|
||||
const res = await this.info();
|
||||
this.multiaddrWithId = multiaddr(res.listenStr);
|
||||
this.multiaddrWithId = res.listenAddresses.map((ma) => multiaddr(ma))[0];
|
||||
if (!this.multiaddrWithId) throw 'Nim-waku did not return a multiaddr';
|
||||
const peerIdStr = this.multiaddrWithId.getPeerId();
|
||||
if (!peerIdStr) throw 'Nim-waku multiaddr does not contain peerId';
|
||||
this.peerId = PeerId.createFromB58String(peerIdStr);
|
||||
|
@ -411,6 +412,6 @@ export function bufToHex(buffer: Uint8Array): string {
|
|||
}
|
||||
|
||||
interface RpcInfoResponse {
|
||||
// multiaddr including id.
|
||||
listenStr: string;
|
||||
// multiaddrs including peer id.
|
||||
listenAddresses: string[];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue