js-waku/src/lib/waku.spec.ts

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-03-22 16:02:10 +11:00
import { expect } from 'chai';
2021-04-01 18:27:15 +11:00
import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../test_utils/';
2021-03-10 17:39:53 +11:00
2021-03-19 14:40:16 +11:00
import Waku from './waku';
import { RelayCodec } from './waku_relay';
2021-03-22 16:02:10 +11:00
describe('Waku', function () {
describe('Interop: Nim', function () {
it('nim connects to js', async function () {
this.timeout(10_000);
2021-03-29 13:56:17 +11:00
const waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 });
2021-03-10 17:39:53 +11:00
2021-04-06 11:06:10 +10:00
const multiAddrWithId = waku.getLocalMultiaddrWithID();
2021-03-11 10:54:35 +11:00
2021-03-25 15:49:07 +11:00
const nimWaku = new NimWaku(makeLogFileName(this));
2021-03-19 15:03:31 +11:00
await nimWaku.start({ staticnode: multiAddrWithId });
2021-03-10 17:39:53 +11:00
2021-03-19 15:03:31 +11:00
const nimPeers = await nimWaku.peers();
2021-03-10 17:39:53 +11:00
2021-03-22 16:02:10 +11:00
expect(nimPeers).to.deep.equal([
2021-03-19 15:03:31 +11:00
{
multiaddr: multiAddrWithId,
protocol: RelayCodec,
2021-03-19 15:03:31 +11:00
connected: true,
},
]);
2021-03-19 15:03:31 +11:00
const nimPeerId = await nimWaku.getPeerId();
const jsPeers = waku.libp2p.peerStore.peers;
2021-03-22 16:02:10 +11:00
expect(jsPeers.has(nimPeerId.toB58String())).to.be.true;
nimWaku.stop();
await waku.stop();
2021-03-19 15:03:31 +11:00
});
});
2021-03-10 17:39:53 +11:00
});