2021-03-22 16:02:10 +11:00
|
|
|
import { expect } from 'chai';
|
2021-07-14 12:25:23 +10:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore: No types available
|
2021-04-15 11:19:26 +10:00
|
|
|
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
|
|
|
|
2021-05-10 15:26:14 +10:00
|
|
|
import { Waku } from './waku';
|
2021-03-10 16:25:54 +11:00
|
|
|
|
2021-04-15 11:19:26 +10:00
|
|
|
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);
|
2021-04-15 11:19:26 +10:00
|
|
|
const waku = await Waku.create({
|
|
|
|
staticNoiseKey: NOISE_KEY_1,
|
2021-06-08 22:01:48 +10:00
|
|
|
libp2p: {
|
|
|
|
addresses: { listen: ['/ip4/0.0.0.0/tcp/0'] },
|
|
|
|
modules: { transport: [TCP] },
|
|
|
|
},
|
2021-04-15 11:19:26 +10:00
|
|
|
});
|
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,
|
2021-07-26 11:04:34 +10:00
|
|
|
protocol: '/vac/waku/relay/2.0.0',
|
2021-03-19 15:03:31 +11:00
|
|
|
connected: true,
|
|
|
|
},
|
|
|
|
]);
|
2021-03-11 15:02:29 +11:00
|
|
|
|
2021-03-19 15:03:31 +11:00
|
|
|
const nimPeerId = await nimWaku.getPeerId();
|
|
|
|
const jsPeers = waku.libp2p.peerStore.peers;
|
2021-03-11 15:02:29 +11:00
|
|
|
|
2021-03-22 16:02:10 +11:00
|
|
|
expect(jsPeers.has(nimPeerId.toB58String())).to.be.true;
|
2021-03-19 16:07:56 +11:00
|
|
|
|
|
|
|
nimWaku.stop();
|
|
|
|
await waku.stop();
|
2021-03-19 15:03:31 +11:00
|
|
|
});
|
|
|
|
});
|
2021-03-10 17:39:53 +11:00
|
|
|
});
|