mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-16 22:37:07 +00:00
Check peer ids on both side when connecting
This commit is contained in:
parent
057f5f80ab
commit
f0c9c3ef50
@ -23,7 +23,6 @@ test('Can publish message', async (t) => {
|
||||
await wakuRelayNode2.subscribe();
|
||||
|
||||
// Setup the promise before publishing to ensure the event is not missed
|
||||
// TODO: Is it possible to import `Message` type?
|
||||
const promise = waitForNextData(node1.pubsub);
|
||||
|
||||
await delay(500);
|
||||
@ -63,10 +62,21 @@ test('Nim-waku: nim-waku node connects to js node', async (t) => {
|
||||
const nimWaku = new NimWaku();
|
||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||
|
||||
const peers = await nimWaku.peers();
|
||||
const nimPeers = await nimWaku.peers();
|
||||
|
||||
console.log(peers);
|
||||
t.is(peers.length, 1);
|
||||
t.deepEqual(nimPeers, [
|
||||
{
|
||||
multiaddr: multiAddrWithId,
|
||||
protocol: CODEC,
|
||||
connected: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const nimAddress = await nimWaku.info().then((info) => info.listenStr);
|
||||
const nimPeerId = nimAddress.match(/[\d\w]+$/)[0];
|
||||
const jsPeers = node.peerStore.peers;
|
||||
|
||||
t.true(jsPeers.has(nimPeerId));
|
||||
});
|
||||
|
||||
function waitForNextData(pubsub: Pubsub): Promise<Message> {
|
||||
|
@ -2,8 +2,6 @@ import { fc, testProp } from 'ava-fast-check';
|
||||
|
||||
import { Message } from './waku_message';
|
||||
|
||||
// for all a, b, c strings
|
||||
// b is a substring of a + b + c
|
||||
testProp(
|
||||
'Waku message round trip binary serialisation',
|
||||
[fc.string()],
|
||||
|
@ -40,7 +40,6 @@ export class NimWaku {
|
||||
const logFile = await openAsync(logPath, 'w');
|
||||
|
||||
const mergedArgs = argsToArray(mergeArguments(args));
|
||||
console.log(mergedArgs);
|
||||
this.process = spawn(NIM_WAKU_BIN, mergedArgs, {
|
||||
cwd: '/home/froyer/src/status-im/nim-waku/',
|
||||
stdio: [
|
||||
@ -56,14 +55,13 @@ export class NimWaku {
|
||||
|
||||
await waitForLine(logPath, 'RPC Server started');
|
||||
console.log('Nim waku RPC is started');
|
||||
console.log(await this.info());
|
||||
}
|
||||
|
||||
/** Calls nim-waku2 JSON-RPC API `get_waku_v2_admin_v1_peers` to check
|
||||
* for known peers
|
||||
* @throws if nim-waku2 isn't started.
|
||||
*/
|
||||
async peers(): Promise<string[]> {
|
||||
async peers() {
|
||||
this.checkProcess();
|
||||
|
||||
const res = await this.rpcCall('get_waku_v2_admin_v1_peers', []);
|
||||
|
Loading…
x
Reference in New Issue
Block a user