Use multiaddr lib instead of string parsing

This commit is contained in:
Franck Royer 2021-03-12 17:01:14 +11:00
parent a7c666f108
commit a0d6784e3c
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import test from 'ava'; import test from 'ava';
import Pubsub from 'libp2p-interfaces/src/pubsub'; import Pubsub from 'libp2p-interfaces/src/pubsub';
import multiaddr from 'multiaddr';
import { delay } from '../test_utils/delay'; import { delay } from '../test_utils/delay';
import { NimWaku } from '../test_utils/nim_waku'; import { NimWaku } from '../test_utils/nim_waku';
@ -96,7 +97,7 @@ test('Nim-interop: js node subscribes to default waku topic (only checking js si
await wakuRelayNode.subscribe(); await wakuRelayNode.subscribe();
const nimAddress = await nimWaku.info().then((info) => info.listenStr); const nimAddress = await nimWaku.info().then((info) => info.listenStr);
const nimPeerId = nimAddress.match(/[\d\w]+$/)[0]; const nimPeerId = multiaddr(nimAddress).getPeerId();
const subscribers = node.pubsub.getSubscribers(TOPIC); const subscribers = node.pubsub.getSubscribers(TOPIC);
t.true(subscribers.includes(nimPeerId)); t.true(subscribers.includes(nimPeerId));