Split browser and node tests

This commit is contained in:
Franck Royer 2021-07-14 11:44:07 +10:00
parent 4f8d8b099b
commit 70058f0e36
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 30 additions and 28 deletions

View File

@ -0,0 +1,29 @@
import { expect } from 'chai';
import { NOISE_KEY_1, NOISE_KEY_2 } from '../test_utils/';
import { Waku } from './waku';
describe('Waku Dial', function () {
it('js connects to js', async function () {
this.timeout(10_000);
const [waku1, waku2] = await Promise.all([
Waku.create({
staticNoiseKey: NOISE_KEY_1,
libp2p: { addresses: { listen: ['/ip4/0.0.0.0/tcp/0/ws'] } },
}),
Waku.create({ staticNoiseKey: NOISE_KEY_2 }),
]);
const waku1MultiAddrWithId = waku1.getLocalMultiaddrWithID();
await waku2.dial(waku1MultiAddrWithId);
const waku2PeerId = waku2.libp2p.peerId;
const waku1Peers = waku1.libp2p.peerStore.peers;
expect(waku1Peers.has(waku2PeerId.toB58String())).to.be.true;
await Promise.all([waku1.stop(), waku2.stop()]);
});
});

View File

@ -1,39 +1,12 @@
import { expect } from 'chai'; import { expect } from 'chai';
import TCP from 'libp2p-tcp'; import TCP from 'libp2p-tcp';
import { import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../test_utils/';
makeLogFileName,
NimWaku,
NOISE_KEY_1,
NOISE_KEY_2,
} from '../test_utils/';
import { Waku } from './waku'; import { Waku } from './waku';
import { RelayCodec } from './waku_relay'; import { RelayCodec } from './waku_relay';
describe('Waku Dial', function () { describe('Waku Dial', function () {
it('js connects to js', async function () {
this.timeout(10_000);
const [waku1, waku2] = await Promise.all([
Waku.create({
staticNoiseKey: NOISE_KEY_1,
libp2p: { addresses: { listen: ['/ip4/0.0.0.0/tcp/0/ws'] } },
}),
Waku.create({ staticNoiseKey: NOISE_KEY_2 }),
]);
const waku1MultiAddrWithId = waku1.getLocalMultiaddrWithID();
await waku2.dial(waku1MultiAddrWithId);
const waku2PeerId = waku2.libp2p.peerId;
const waku1Peers = waku1.libp2p.peerStore.peers;
expect(waku1Peers.has(waku2PeerId.toB58String())).to.be.true;
await Promise.all([waku1.stop(), waku2.stop()]);
});
describe('Interop: Nim', function () { describe('Interop: Nim', function () {
it('nim connects to js', async function () { it('nim connects to js', async function () {
this.timeout(10_000); this.timeout(10_000);