mirror of https://github.com/waku-org/js-waku.git
fix(tests): sharding (#1893)
This commit is contained in:
parent
36dfcc9560
commit
49c39682e4
|
@ -72,33 +72,45 @@ describe("getConnectedPeersForProtocolAndShard", function () {
|
||||||
expect(peers.length).to.be.greaterThan(0);
|
expect(peers.length).to.be.greaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Had to use cluster 0 because of https://github.com/waku-org/js-waku/issues/1848
|
it("same cluster, different shard: nodes don't connect", async function () {
|
||||||
it("same cluster, different shard: nodes connect", async function () {
|
|
||||||
this.timeout(15000);
|
this.timeout(15000);
|
||||||
|
|
||||||
const shardInfo: ShardInfo = {
|
const shardInfo1: ShardInfo = {
|
||||||
clusterId: 0,
|
clusterId: 2,
|
||||||
shards: [1]
|
shards: [1]
|
||||||
};
|
};
|
||||||
|
|
||||||
const shardInfoServiceNode: ShardInfo = {
|
const shardInfo2: ShardInfo = {
|
||||||
clusterId: 0,
|
clusterId: 2,
|
||||||
shards: [1]
|
shards: [2]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Separate shard
|
||||||
await serviceNode1.start({
|
await serviceNode1.start({
|
||||||
discv5Discovery: true,
|
discv5Discovery: true,
|
||||||
peerExchange: true,
|
peerExchange: true,
|
||||||
clusterId: shardInfoServiceNode.clusterId,
|
clusterId: shardInfo1.clusterId,
|
||||||
pubsubTopic: shardInfoToPubsubTopics(shardInfoServiceNode),
|
pubsubTopic: shardInfoToPubsubTopics(shardInfo1),
|
||||||
lightpush: true,
|
lightpush: true,
|
||||||
relay: true
|
relay: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const serviceNodeMa = await serviceNode1.getMultiaddrWithId();
|
// Same shard
|
||||||
|
await serviceNode2.start({
|
||||||
|
discv5Discovery: true,
|
||||||
|
peerExchange: true,
|
||||||
|
clusterId: shardInfo2.clusterId,
|
||||||
|
pubsubTopic: shardInfoToPubsubTopics(shardInfo2),
|
||||||
|
lightpush: true,
|
||||||
|
relay: true
|
||||||
|
});
|
||||||
|
|
||||||
waku = await createLightNode({ shardInfo });
|
const serviceNode1Ma = await serviceNode1.getMultiaddrWithId();
|
||||||
await waku.libp2p.dialProtocol(serviceNodeMa, LightPushCodec);
|
const serviceNode2Ma = await serviceNode2.getMultiaddrWithId();
|
||||||
|
|
||||||
|
waku = await createLightNode({ shardInfo: shardInfo2 });
|
||||||
|
await waku.libp2p.dialProtocol(serviceNode1Ma, LightPushCodec);
|
||||||
|
await waku.libp2p.dialProtocol(serviceNode2Ma, LightPushCodec);
|
||||||
await waku.start();
|
await waku.start();
|
||||||
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
||||||
|
|
||||||
|
@ -106,9 +118,9 @@ describe("getConnectedPeersForProtocolAndShard", function () {
|
||||||
waku.libp2p.getConnections(),
|
waku.libp2p.getConnections(),
|
||||||
waku.libp2p.peerStore,
|
waku.libp2p.peerStore,
|
||||||
waku.libp2p.getProtocols(),
|
waku.libp2p.getProtocols(),
|
||||||
shardInfo
|
ensureShardingConfigured(shardInfo2).shardInfo
|
||||||
);
|
);
|
||||||
expect(peers.length).to.be.greaterThan(0);
|
expect(peers.length).to.be.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("different cluster, same shard: nodes don't connect", async function () {
|
it("different cluster, same shard: nodes don't connect", async function () {
|
||||||
|
|
Loading…
Reference in New Issue