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

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-03-22 16:02:10 +11:00
import { expect } from 'chai';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: No types available
import TCP from 'libp2p-tcp';
2021-03-22 16:02:10 +11:00
2021-07-14 11:44:07 +10:00
import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../test_utils/';
2021-03-10 17:39:53 +11:00
import { Waku } from './waku';
describe('Waku Dial', function () {
2021-03-22 16:02:10 +11:00
describe('Interop: Nim', function () {
it('nim connects to js', async function () {
this.timeout(10_000);
const waku = await Waku.create({
staticNoiseKey: NOISE_KEY_1,
libp2p: {
addresses: { listen: ['/ip4/0.0.0.0/tcp/0'] },
modules: { transport: [TCP] },
},
});
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: '/vac/waku/relay/2.0.0',
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
});