mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-19 15:54:28 +00:00
Merge branch 'master' of github.com:waku-org/js-waku into feat/shard-peer-selection
This commit is contained in:
commit
84fd1cf3fd
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -85,14 +85,14 @@ jobs:
|
||||
node_with_go_waku_master:
|
||||
uses: ./.github/workflows/test-node.yml
|
||||
with:
|
||||
nim_wakunode_image: wakuorg/go-waku:latest
|
||||
nim_wakunode_image: harbor.status.im/wakuorg/go-waku:latest
|
||||
test_type: go-waku-master
|
||||
debug: waku*
|
||||
|
||||
node_with_nwaku_master:
|
||||
uses: ./.github/workflows/test-node.yml
|
||||
with:
|
||||
nim_wakunode_image: wakuorg/nwaku:deploy-wakuv2-test
|
||||
nim_wakunode_image: harbor.status.im/wakuorg/nwaku:latest
|
||||
test_type: nwaku-master
|
||||
debug: waku*
|
||||
|
||||
|
16430
package-lock.json
generated
16430
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -60,7 +60,7 @@
|
||||
"playwright": "^1.40.1",
|
||||
"size-limit": "^11.0.1",
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typedoc": "^0.25.1",
|
||||
"typescript": "^5.3.2"
|
||||
},
|
||||
|
@ -72,6 +72,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@libp2p/ping": "^1.0.9",
|
||||
"@noble/hashes": "^1.3.2",
|
||||
"@waku/enr": "^0.0.20",
|
||||
"@waku/interfaces": "0.0.21",
|
||||
@ -103,11 +104,11 @@
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"process": "^0.11.10",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@multiformats/multiaddr": "^12.0.0",
|
||||
"libp2p": "^0.46.3"
|
||||
"libp2p": "^1.1.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@multiformats/multiaddr": {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { Libp2p } from "@libp2p/interface";
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import { Peer, PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { Peer, PeerStore, Stream } from "@libp2p/interface";
|
||||
import type {
|
||||
IBaseProtocol,
|
||||
Libp2pComponents,
|
||||
@ -82,7 +81,7 @@ export class BaseProtocol implements IBaseProtocol {
|
||||
*
|
||||
* @param numPeers - The total number of peers to retrieve. If 0, all peers are returned.
|
||||
* @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.
|
||||
|
||||
|
||||
* @returns A list of peers that support the protocol sorted by latency.
|
||||
*/
|
||||
protected async getPeers(
|
||||
|
@ -1,8 +1,5 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
import type { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { PeerStore } from "@libp2p/interface/peer-store";
|
||||
import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
|
||||
import type { Peer, PeerId, PeerInfo, PeerStore } from "@libp2p/interface";
|
||||
import { CustomEvent, TypedEventEmitter } from "@libp2p/interface";
|
||||
import {
|
||||
ConnectionManagerOptions,
|
||||
EConnectionStateEvents,
|
||||
@ -17,8 +14,7 @@ import {
|
||||
ShardInfo
|
||||
} from "@waku/interfaces";
|
||||
import { Libp2p, Tags } from "@waku/interfaces";
|
||||
import { decodeRelayShard, shardInfoToPubsubTopics } from "@waku/utils";
|
||||
import { Logger } from "@waku/utils";
|
||||
import { decodeRelayShard, Logger, shardInfoToPubsubTopics } from "@waku/utils";
|
||||
|
||||
import { KeepAliveManager } from "./keep_alive_manager.js";
|
||||
|
||||
@ -29,7 +25,7 @@ export const DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;
|
||||
export const DEFAULT_MAX_PARALLEL_DIALS = 3;
|
||||
|
||||
export class ConnectionManager
|
||||
extends EventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents>
|
||||
extends TypedEventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents>
|
||||
implements IConnectionManager
|
||||
{
|
||||
private static instances = new Map<string, ConnectionManager>();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Stream } from "@libp2p/interface/connection";
|
||||
import type { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { IncomingStreamData } from "@libp2p/interface-internal/registrar";
|
||||
import { Stream } from "@libp2p/interface";
|
||||
import type { Peer } from "@libp2p/interface";
|
||||
import type { IncomingStreamData } from "@libp2p/interface-internal";
|
||||
import type {
|
||||
Callback,
|
||||
ContentTopic,
|
||||
@ -304,6 +304,10 @@ class Filter extends BaseProtocol implements IReceiver {
|
||||
})
|
||||
)[0];
|
||||
|
||||
if (!peer) {
|
||||
throw new Error("No peer found to initiate subscription.");
|
||||
}
|
||||
|
||||
const subscription =
|
||||
this.getActiveSubscription(pubsubTopic, peer.id.toString()) ??
|
||||
this.setActiveSubscription(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { Tag } from "@libp2p/interface/peer-store";
|
||||
import { Peer } from "@libp2p/interface";
|
||||
import type { Tag } from "@libp2p/interface";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { Tags } from "@waku/interfaces";
|
||||
import { expect } from "chai";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Peer } from "@libp2p/interface/peer-store";
|
||||
import { Peer } from "@libp2p/interface";
|
||||
import { Tags } from "@waku/interfaces";
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,9 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { PeerId, PeerStore } from "@libp2p/interface";
|
||||
import type { PingService } from "@libp2p/ping";
|
||||
import type { IRelay, PeerIdStr } from "@waku/interfaces";
|
||||
import type { KeepAliveOptions } from "@waku/interfaces";
|
||||
import { Logger, pubsubTopicToSingleShardInfo } from "@waku/utils";
|
||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
import type { PingService } from "libp2p/ping";
|
||||
|
||||
import { createEncoder } from "./message/version_0.js";
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId, Stream } from "@libp2p/interface";
|
||||
import {
|
||||
IEncoder,
|
||||
ILightPush,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import { IncomingStreamData } from "@libp2p/interface/stream-handler";
|
||||
import { IncomingStreamData, type PeerId } from "@libp2p/interface";
|
||||
import type {
|
||||
IMetadata,
|
||||
Libp2pComponents,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import type { Stream } from "@libp2p/interface";
|
||||
import { sha256 } from "@noble/hashes/sha256";
|
||||
import {
|
||||
Cursor,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { PeerUpdate } from "@libp2p/interface";
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { PeerUpdate, Stream } from "@libp2p/interface";
|
||||
import { Peer } from "@libp2p/interface";
|
||||
import { Libp2p } from "@waku/interfaces";
|
||||
import { Logger } from "@waku/utils";
|
||||
import { selectConnection } from "@waku/utils/libp2p";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import { isPeerId, PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { Stream } from "@libp2p/interface";
|
||||
import { isPeerId, PeerId } from "@libp2p/interface";
|
||||
import { multiaddr, Multiaddr, MultiaddrInput } from "@multiformats/multiaddr";
|
||||
import type {
|
||||
IFilter,
|
||||
@ -189,7 +189,7 @@ export class WakuNode implements Waku {
|
||||
}
|
||||
|
||||
isStarted(): boolean {
|
||||
return this.libp2p.isStarted();
|
||||
return this.libp2p.status == "started";
|
||||
}
|
||||
|
||||
isConnected(): boolean {
|
||||
|
@ -59,8 +59,8 @@
|
||||
"uint8arrays": "^4.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/peer-id": "^3.0.3",
|
||||
"@libp2p/peer-id-factory": "^3.0.3",
|
||||
"@libp2p/peer-id": "^4.0.4",
|
||||
"@libp2p/peer-id-factory": "^4.0.4",
|
||||
"@multiformats/multiaddr": "^12.0.0",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
@ -72,7 +72,7 @@
|
||||
"cspell": "^7.3.2",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { CustomEvent, EventEmitter } from "@libp2p/interface/events";
|
||||
import type {
|
||||
import {
|
||||
CustomEvent,
|
||||
PeerDiscovery,
|
||||
PeerDiscoveryEvents
|
||||
} from "@libp2p/interface/peer-discovery";
|
||||
import { peerDiscovery as symbol } from "@libp2p/interface/peer-discovery";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
PeerDiscoveryEvents,
|
||||
type PeerInfo,
|
||||
peerDiscoverySymbol as symbol,
|
||||
TypedEventEmitter
|
||||
} from "@libp2p/interface";
|
||||
import type {
|
||||
DnsDiscOptions,
|
||||
DnsDiscoveryComponents,
|
||||
@ -27,7 +28,7 @@ const log = new Logger("peer-discovery-dns");
|
||||
* Parse options and expose function to return bootstrap peer addresses.
|
||||
*/
|
||||
export class PeerDiscoveryDns
|
||||
extends EventEmitter<PeerDiscoveryEvents>
|
||||
extends TypedEventEmitter<PeerDiscoveryEvents>
|
||||
implements PeerDiscovery
|
||||
{
|
||||
private nextPeer: (() => AsyncGenerator<IEnr>) | undefined;
|
||||
|
@ -52,8 +52,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethersproject/rlp": "^5.7.0",
|
||||
"@libp2p/crypto": "^3.0.2",
|
||||
"@libp2p/peer-id": "^3.0.3",
|
||||
"@libp2p/crypto": "^4.0.0",
|
||||
"@libp2p/peer-id": "^4.0.4",
|
||||
"@multiformats/multiaddr": "^12.0.0",
|
||||
"@noble/secp256k1": "^1.7.1",
|
||||
"@waku/utils": "0.0.14",
|
||||
@ -61,7 +61,7 @@
|
||||
"js-sha3": "^0.9.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/peer-id-factory": "^3.0.3",
|
||||
"@libp2p/peer-id-factory": "^4.0.4",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
@ -75,7 +75,7 @@
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"process": "^0.11.10",
|
||||
"rollup": "^4.6.0",
|
||||
"rollup": "^4.9.5",
|
||||
"uint8arrays": "^4.0.4"
|
||||
},
|
||||
"files": [
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { ENRKey, ENRValue } from "@waku/interfaces";
|
||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import * as secp from "@noble/secp256k1";
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
import type { PeerId, PeerInfo } from "@libp2p/interface";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import type {
|
||||
ENRKey,
|
||||
@ -116,8 +115,7 @@ export class ENR extends RawEnr implements IEnr {
|
||||
if (!id) return;
|
||||
return {
|
||||
id,
|
||||
multiaddrs: this.getAllLocationMultiaddrs(),
|
||||
protocols: []
|
||||
multiaddrs: this.getAllLocationMultiaddrs()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { unmarshalPrivateKey, unmarshalPublicKey } from "@libp2p/crypto/keys";
|
||||
import { supportedKeys } from "@libp2p/crypto/keys";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { peerIdFromKeys } from "@libp2p/peer-id";
|
||||
|
||||
export function createPeerIdFromPublicKey(
|
||||
|
@ -47,11 +47,11 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^10.1.1",
|
||||
"@chainsafe/libp2p-gossipsub": "^11.1.0",
|
||||
"@multiformats/multiaddr": "^12.0.0",
|
||||
"cspell": "^7.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"libp2p": "^0.46.14"
|
||||
"libp2p": "^1.1.2"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -1,6 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { EventEmitter } from "@libp2p/interfaces/events";
|
||||
import type { Peer, PeerId, TypedEventEmitter } from "@libp2p/interface";
|
||||
|
||||
export enum Tags {
|
||||
BOOTSTRAP = "bootstrap",
|
||||
@ -59,7 +57,7 @@ export interface IConnectionStateEvents {
|
||||
}
|
||||
|
||||
export interface IConnectionManager
|
||||
extends EventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents> {
|
||||
extends TypedEventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents> {
|
||||
getPeersByDiscovery(): Promise<PeersByDiscoveryResult>;
|
||||
stop(): void;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { PeerStore } from "@libp2p/interface/peer-store";
|
||||
import { PeerStore } from "@libp2p/interface";
|
||||
|
||||
export type SearchContext = {
|
||||
domain: string;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { PeerInfo } from "@libp2p/interface";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
|
||||
export type ENRKey = string;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
|
||||
import type { IDecodedMessage, IDecoder, SingleShardInfo } from "./message.js";
|
||||
import type { ContentTopic, PubsubTopic } from "./misc.js";
|
||||
|
@ -1,8 +1,8 @@
|
||||
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
||||
import type { identify } from "@libp2p/identify";
|
||||
import type { Libp2p as BaseLibp2p } from "@libp2p/interface";
|
||||
import type { PingService } from "@libp2p/ping";
|
||||
import type { Libp2pInit, Libp2pOptions } from "libp2p";
|
||||
import type { identifyService } from "libp2p/identify";
|
||||
import type { PingService } from "libp2p/ping";
|
||||
|
||||
import { IMetadata } from "./metadata";
|
||||
|
||||
@ -10,7 +10,7 @@ export type Libp2pServices = {
|
||||
ping: PingService;
|
||||
metadata?: IMetadata;
|
||||
pubsub?: GossipSub;
|
||||
identify: ReturnType<ReturnType<typeof identifyService>>;
|
||||
identify: ReturnType<ReturnType<typeof identify>>;
|
||||
};
|
||||
|
||||
// TODO: Get libp2p to export this.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
|
||||
import type { ShardInfo } from "./enr.js";
|
||||
import type { IBaseProtocol, ShardingParams } from "./protocols.js";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { ConnectionManager } from "@libp2p/interface-internal/connection-manager";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { PeerStore } from "@libp2p/interface";
|
||||
import type { ConnectionManager } from "@libp2p/interface-internal";
|
||||
|
||||
import { IEnr } from "./enr.js";
|
||||
import { IBaseProtocol } from "./protocols.js";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { Libp2p } from "@libp2p/interface";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { Peer, PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { Peer, PeerStore } from "@libp2p/interface";
|
||||
|
||||
import type { ShardInfo } from "./enr.js";
|
||||
import type { CreateLibp2pOptions } from "./libp2p.js";
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { Stream } from "@libp2p/interface/connection";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId, Stream } from "@libp2p/interface";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
|
||||
import { IConnectionManager } from "./connection_manager.js";
|
||||
|
@ -97,7 +97,7 @@
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"process": "^0.11.10",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -70,7 +70,7 @@
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"process": "^0.11.10",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -67,7 +67,7 @@
|
||||
"chai": "^4.3.10",
|
||||
"cspell": "^7.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^4.6.0",
|
||||
"rollup": "^4.9.5",
|
||||
"uint8arraylist": "^2.4.3"
|
||||
},
|
||||
"files": [
|
||||
|
@ -1,12 +1,13 @@
|
||||
import type { IdentifyResult } from "@libp2p/interface";
|
||||
import { CustomEvent, EventEmitter } from "@libp2p/interface/events";
|
||||
import type {
|
||||
import {
|
||||
CustomEvent,
|
||||
IdentifyResult,
|
||||
PeerDiscovery,
|
||||
PeerDiscoveryEvents
|
||||
} from "@libp2p/interface/peer-discovery";
|
||||
import { peerDiscovery as symbol } from "@libp2p/interface/peer-discovery";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
PeerDiscoveryEvents,
|
||||
PeerId,
|
||||
PeerInfo,
|
||||
peerDiscoverySymbol as symbol,
|
||||
TypedEventEmitter
|
||||
} from "@libp2p/interface";
|
||||
import { Libp2pComponents, Tags } from "@waku/interfaces";
|
||||
import { encodeRelayShard, Logger } from "@waku/utils";
|
||||
|
||||
@ -50,7 +51,7 @@ const DEFAULT_PEER_EXCHANGE_TAG_VALUE = 50;
|
||||
const DEFAULT_PEER_EXCHANGE_TAG_TTL = 100_000_000;
|
||||
|
||||
export class PeerExchangeDiscovery
|
||||
extends EventEmitter<PeerDiscoveryEvents>
|
||||
extends TypedEventEmitter<PeerDiscoveryEvents>
|
||||
implements PeerDiscovery
|
||||
{
|
||||
private readonly components: Libp2pComponents;
|
||||
@ -205,7 +206,6 @@ export class PeerExchangeDiscovery
|
||||
new CustomEvent<PeerInfo>("peer", {
|
||||
detail: {
|
||||
id: peerId,
|
||||
protocols: [],
|
||||
multiaddrs: peerInfo.multiaddrs
|
||||
}
|
||||
})
|
||||
|
@ -54,7 +54,7 @@
|
||||
"cspell": "^7.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"protons": "^7.0.2",
|
||||
"rollup": "^4.6.0",
|
||||
"rollup": "^4.9.5",
|
||||
"uint8arraylist": "^2.4.3"
|
||||
},
|
||||
"files": [
|
||||
|
@ -49,7 +49,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^10.1.1",
|
||||
"@chainsafe/libp2p-gossipsub": "^11.1.0",
|
||||
"@noble/hashes": "^1.3.2",
|
||||
"@waku/core": "0.0.26",
|
||||
"@waku/interfaces": "0.0.21",
|
||||
@ -64,7 +64,7 @@
|
||||
"@waku/build-utils": "*",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -6,8 +6,7 @@ import {
|
||||
} from "@chainsafe/libp2p-gossipsub";
|
||||
import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types";
|
||||
import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PubSub as Libp2pPubsub } from "@libp2p/interface/pubsub";
|
||||
import type { PubSub as Libp2pPubsub, PeerId } from "@libp2p/interface";
|
||||
import { sha256 } from "@noble/hashes/sha256";
|
||||
import {
|
||||
ActiveSubscriptions,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { TopicValidatorResult } from "@libp2p/interface/pubsub";
|
||||
import type { UnsignedMessage } from "@libp2p/interface/pubsub";
|
||||
import { TopicValidatorResult } from "@libp2p/interface";
|
||||
import type { UnsignedMessage } from "@libp2p/interface";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { createEncoder } from "@waku/core";
|
||||
import { expect } from "chai";
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { Message } from "@libp2p/interface/pubsub";
|
||||
import { TopicValidatorResult } from "@libp2p/interface/pubsub";
|
||||
import type { Message, PeerId } from "@libp2p/interface";
|
||||
import { TopicValidatorResult } from "@libp2p/interface";
|
||||
import { proto_message as proto } from "@waku/proto";
|
||||
import { Logger } from "@waku/utils";
|
||||
|
||||
|
@ -61,19 +61,21 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "^13.0.4",
|
||||
"@libp2p/mplex": "^9.0.10",
|
||||
"@libp2p/websockets": "^7.0.5",
|
||||
"@waku/utils": "0.0.14",
|
||||
"@waku/relay": "0.0.9",
|
||||
"@chainsafe/libp2p-noise": "^14.1.0",
|
||||
"@libp2p/identify": "^1.0.10",
|
||||
"@libp2p/mplex": "^10.0.12",
|
||||
"@libp2p/ping": "^1.0.9",
|
||||
"@libp2p/websockets": "^8.0.11",
|
||||
"@waku/core": "0.0.26",
|
||||
"@waku/dns-discovery": "0.0.20",
|
||||
"@waku/interfaces": "0.0.21",
|
||||
"@waku/peer-exchange": "^0.0.19",
|
||||
"libp2p": "^0.46.14"
|
||||
"@waku/relay": "0.0.9",
|
||||
"@waku/utils": "0.0.14",
|
||||
"libp2p": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^10.1.1",
|
||||
"@chainsafe/libp2p-gossipsub": "^11.1.0",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
@ -81,7 +83,7 @@
|
||||
"cspell": "^7.3.2",
|
||||
"interface-datastore": "^8.2.10",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^4.6.0"
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -1,7 +1,9 @@
|
||||
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
||||
import { noise } from "@chainsafe/libp2p-noise";
|
||||
import type { PeerDiscovery } from "@libp2p/interface/peer-discovery";
|
||||
import { identify } from "@libp2p/identify";
|
||||
import type { PeerDiscovery } from "@libp2p/interface";
|
||||
import { mplex } from "@libp2p/mplex";
|
||||
import { ping } from "@libp2p/ping";
|
||||
import { webSockets } from "@libp2p/websockets";
|
||||
import { all as filterAll } from "@libp2p/websockets/filters";
|
||||
import {
|
||||
@ -27,8 +29,6 @@ import type {
|
||||
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
|
||||
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "@waku/relay";
|
||||
import { createLibp2p } from "libp2p";
|
||||
import { identifyService } from "libp2p/identify";
|
||||
import { pingService } from "libp2p/ping";
|
||||
|
||||
const DEFAULT_NODE_REQUIREMENTS = {
|
||||
lightPush: 1,
|
||||
@ -242,10 +242,10 @@ export async function defaultLibp2p(
|
||||
connectionEncryption: [noise()],
|
||||
...options,
|
||||
services: {
|
||||
identify: identifyService({
|
||||
identify: identify({
|
||||
agentVersion: userAgent ?? DefaultUserAgent
|
||||
}),
|
||||
ping: pingService(),
|
||||
ping: ping(),
|
||||
...metadataService,
|
||||
...pubsubService,
|
||||
...options?.services
|
||||
|
@ -50,8 +50,8 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@libp2p/interface-compliance-tests": "^4.1.0",
|
||||
"@libp2p/peer-id": "^3.0.3",
|
||||
"@libp2p/interface-compliance-tests": "^5.1.2",
|
||||
"@libp2p/peer-id": "^4.0.4",
|
||||
"@waku/core": "*",
|
||||
"@waku/enr": "*",
|
||||
"@waku/interfaces": "*",
|
||||
@ -68,7 +68,7 @@
|
||||
"tail": "^2.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/bootstrap": "^9.0.10",
|
||||
"@libp2p/bootstrap": "^10.0.11",
|
||||
"@types/chai": "^4.3.11",
|
||||
"@types/dockerode": "^3.3.19",
|
||||
"@types/mocha": "^10.0.1",
|
||||
@ -85,7 +85,7 @@
|
||||
"datastore-core": "^9.2.7",
|
||||
"debug": "^4.3.4",
|
||||
"interface-datastore": "^8.2.10",
|
||||
"libp2p": "^0.46.14",
|
||||
"libp2p": "^1.1.2",
|
||||
"mocha": "^10.2.0",
|
||||
"mocha-multi-reporters": "^1.5.1",
|
||||
"npm-run-all": "^4.1.5"
|
||||
|
@ -5,12 +5,6 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
export * from "./async_fs.js";
|
||||
export * from "./utils/index.js";
|
||||
export * from "./constants.js";
|
||||
export * from "./delay.js";
|
||||
export * from "./log_file.js";
|
||||
export * from "./node/node.js";
|
||||
export * from "./teardown.js";
|
||||
export * from "./message_collector.js";
|
||||
export * from "./utils.js";
|
||||
export * from "./waitForRemotePeerWithCodec.js";
|
||||
export * from "./lib/index.js";
|
||||
|
@ -3,7 +3,7 @@ import fs from "fs";
|
||||
import { Logger } from "@waku/utils";
|
||||
import Docker from "dockerode";
|
||||
|
||||
import { Args } from "./interfaces.js";
|
||||
import { Args } from "../types.js";
|
||||
|
||||
const log = new Logger("test:docker");
|
||||
|
2
packages/tests/src/lib/index.ts
Normal file
2
packages/tests/src/lib/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./message_collector.js";
|
||||
export * from "./service_node.js";
|
@ -5,9 +5,8 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { AssertionError, expect } from "chai";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
import { MessageRpcResponse } from "./node/interfaces.js";
|
||||
|
||||
import { base64ToUtf8, delay, NimGoNode } from "./index.js";
|
||||
import { base64ToUtf8, delay, ServiceNode } from "../index.js";
|
||||
import { MessageRpcResponse } from "../types.js";
|
||||
|
||||
const log = new Logger("test:message-collector");
|
||||
|
||||
@ -20,7 +19,7 @@ export class MessageCollector {
|
||||
list: Array<MessageRpcResponse | DecodedMessage> = [];
|
||||
callback: (msg: DecodedMessage) => void = () => {};
|
||||
|
||||
constructor(private nwaku?: NimGoNode) {
|
||||
constructor(private nwaku?: ServiceNode) {
|
||||
if (!this.nwaku) {
|
||||
this.callback = (msg: DecodedMessage): void => {
|
||||
log.info("Got a message");
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { peerIdFromString } from "@libp2p/peer-id";
|
||||
import { Multiaddr, multiaddr } from "@multiformats/multiaddr";
|
||||
import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
@ -8,18 +8,18 @@ import { bytesToHex, hexToBytes } from "@waku/utils/bytes";
|
||||
import pRetry from "p-retry";
|
||||
import portfinder from "portfinder";
|
||||
|
||||
import { existsAsync, mkdirAsync, openAsync } from "../async_fs.js";
|
||||
import { delay } from "../delay.js";
|
||||
import waitForLine from "../log_file.js";
|
||||
|
||||
import Dockerode from "./dockerode.js";
|
||||
import {
|
||||
Args,
|
||||
KeyPair,
|
||||
LogLevel,
|
||||
MessageRpcQuery,
|
||||
MessageRpcResponse
|
||||
} from "./interfaces.js";
|
||||
} from "../types.js";
|
||||
import { existsAsync, mkdirAsync, openAsync } from "../utils/async_fs.js";
|
||||
import { delay } from "../utils/delay.js";
|
||||
import waitForLine from "../utils/log_file.js";
|
||||
|
||||
import Dockerode from "./dockerode.js";
|
||||
|
||||
const log = new Logger("test:node");
|
||||
|
||||
@ -27,7 +27,8 @@ const WAKU_SERVICE_NODE_PARAMS =
|
||||
process.env.WAKU_SERVICE_NODE_PARAMS ?? undefined;
|
||||
const NODE_READY_LOG_LINE = "Node setup complete";
|
||||
|
||||
const DOCKER_IMAGE_NAME = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.22.0";
|
||||
export const DOCKER_IMAGE_NAME =
|
||||
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.22.0";
|
||||
|
||||
const isGoWaku = DOCKER_IMAGE_NAME.includes("go-waku");
|
||||
|
||||
@ -41,7 +42,7 @@ BigInt.prototype.toJSON = function toJSON() {
|
||||
return Number(this);
|
||||
};
|
||||
|
||||
export class NimGoNode {
|
||||
export class ServiceNode {
|
||||
private docker?: Dockerode;
|
||||
private peerId?: PeerId;
|
||||
private multiaddrWithId?: Multiaddr;
|
||||
@ -464,7 +465,3 @@ interface RpcInfoResponse {
|
||||
listenAddresses: string[];
|
||||
enrUri?: string;
|
||||
}
|
||||
|
||||
export function base64ToUtf8(b64: string): string {
|
||||
return Buffer.from(b64, "base64").toString("utf-8");
|
||||
}
|
@ -28,3 +28,5 @@ export async function waitForFile(path: string): Promise<void> {
|
||||
}
|
||||
} while (!found);
|
||||
}
|
||||
|
||||
export * from "./log_file.js";
|
3
packages/tests/src/utils/base64_utf8.ts
Normal file
3
packages/tests/src/utils/base64_utf8.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function base64ToUtf8(b64: string): string {
|
||||
return Buffer.from(b64, "base64").toString("utf-8");
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
export function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export * from "./async_fs.js";
|
@ -1,5 +1,7 @@
|
||||
import { createDecoder, createEncoder, Decoder, Encoder } from "@waku/core";
|
||||
|
||||
import { DOCKER_IMAGE_NAME } from "../lib/service_node";
|
||||
|
||||
// Utility to generate test data for multiple topics tests.
|
||||
export function generateTestData(topicCount: number): {
|
||||
contentTopics: string[];
|
||||
@ -20,3 +22,19 @@ export function generateTestData(topicCount: number): {
|
||||
decoders
|
||||
};
|
||||
}
|
||||
|
||||
// Utility to add test conditions based on nwaku/go-waku versions
|
||||
export function isNwakuAtLeast(requiredVersion: string): boolean {
|
||||
const versionRegex = /(?:v)?(\d+\.\d+(?:\.\d+)?)/;
|
||||
const match = DOCKER_IMAGE_NAME.match(versionRegex);
|
||||
|
||||
if (match) {
|
||||
const version = match[0].substring(1); // Remove the 'v' prefix
|
||||
return (
|
||||
version.localeCompare(requiredVersion, undefined, { numeric: true }) >= 0
|
||||
);
|
||||
} else {
|
||||
// If there is no match we assume that it's a version close to master so we return True
|
||||
return true;
|
||||
}
|
||||
}
|
6
packages/tests/src/utils/index.ts
Normal file
6
packages/tests/src/utils/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export * from "./generate_test_data.js";
|
||||
export * from "./teardown.js";
|
||||
export * from "./random_array.js";
|
||||
export * from "./wait_for_remote_peer_with_codec.js";
|
||||
export * from "./delay.js";
|
||||
export * from "./base64_utf8.js";
|
@ -2,12 +2,12 @@ import { Waku } from "@waku/interfaces";
|
||||
import { Logger } from "@waku/utils";
|
||||
import pRetry from "p-retry";
|
||||
|
||||
import { NimGoNode } from "./index.js";
|
||||
import { ServiceNode } from "../lib/service_node.js";
|
||||
|
||||
const log = new Logger("test:teardown");
|
||||
|
||||
export async function tearDownNodes(
|
||||
nwakuNodes: NimGoNode | NimGoNode[],
|
||||
nwakuNodes: ServiceNode | ServiceNode[],
|
||||
wakuNodes: Waku | Waku[]
|
||||
): Promise<void> {
|
||||
const nNodes = Array.isArray(nwakuNodes) ? nwakuNodes : [nwakuNodes];
|
@ -1,5 +1,5 @@
|
||||
import type { IdentifyResult } from "@libp2p/interface";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { LightNode } from "@waku/interfaces";
|
||||
|
||||
/**
|
@ -1,6 +1,5 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
import { CustomEvent } from "@libp2p/interfaces/events";
|
||||
import type { PeerId, PeerInfo } from "@libp2p/interface";
|
||||
import { CustomEvent } from "@libp2p/interface";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { Multiaddr } from "@multiformats/multiaddr";
|
||||
import {
|
||||
@ -14,8 +13,8 @@ import { createLightNode } from "@waku/sdk";
|
||||
import { expect } from "chai";
|
||||
import sinon, { SinonSpy, SinonStub } from "sinon";
|
||||
|
||||
import { delay } from "../dist/delay.js";
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../src/index.js";
|
||||
import { delay } from "../src/index.js";
|
||||
import { makeLogFileName, ServiceNode, tearDownNodes } from "../src/index.js";
|
||||
|
||||
const TEST_TIMEOUT = 10_000;
|
||||
const DELAY_MS = 1_000;
|
||||
@ -62,8 +61,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: peerIdBootstrap,
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -96,8 +94,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: peerIdPx,
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -312,8 +309,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: await createSecp256k1PeerId(),
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -377,7 +373,7 @@ describe("ConnectionManager", function () {
|
||||
// emit a peer:discovery event
|
||||
waku.libp2p.dispatchEvent(
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: { id: bootstrapPeer, multiaddrs: [], protocols: [] }
|
||||
detail: { id: bootstrapPeer, multiaddrs: [] }
|
||||
})
|
||||
);
|
||||
|
||||
@ -399,8 +395,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: await createSecp256k1PeerId(),
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -417,8 +412,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: await createSecp256k1PeerId(),
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -443,8 +437,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: pxPeer,
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -469,8 +462,7 @@ describe("ConnectionManager", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: await createSecp256k1PeerId(),
|
||||
multiaddrs: [],
|
||||
protocols: []
|
||||
multiaddrs: []
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -486,15 +478,15 @@ describe("ConnectionManager", function () {
|
||||
|
||||
describe("Connection state", () => {
|
||||
this.timeout(20_000);
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let nwaku1PeerId: Multiaddr;
|
||||
let nwaku2PeerId: Multiaddr;
|
||||
|
||||
beforeEach(async () => {
|
||||
this.timeout(20_000);
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this.ctx) + "1");
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this.ctx) + "2");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this.ctx) + "1");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this.ctx) + "2");
|
||||
await nwaku1.start({
|
||||
filter: true
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { EventEmitter } from "@libp2p/interface/events";
|
||||
import { TypedEventEmitter } from "@libp2p/interface";
|
||||
import tests from "@libp2p/interface-compliance-tests/peer-discovery";
|
||||
import { prefixLogger } from "@libp2p/logger";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { PersistentPeerStore } from "@libp2p/peer-store";
|
||||
import {
|
||||
@ -13,7 +14,7 @@ import { createLightNode } from "@waku/sdk";
|
||||
import { expect } from "chai";
|
||||
import { MemoryDatastore } from "datastore-core/memory";
|
||||
|
||||
import { delay } from "../src/delay.js";
|
||||
import { delay } from "../src/index.js";
|
||||
|
||||
const maxQuantity = 3;
|
||||
|
||||
@ -24,9 +25,10 @@ describe("DNS Discovery: Compliance Test", function () {
|
||||
// create libp2p mock peerStore
|
||||
const components = {
|
||||
peerStore: new PersistentPeerStore({
|
||||
events: new EventEmitter(),
|
||||
events: new TypedEventEmitter(),
|
||||
peerId: await createSecp256k1PeerId(),
|
||||
datastore: new MemoryDatastore()
|
||||
datastore: new MemoryDatastore(),
|
||||
logger: prefixLogger("dns-peer-discovery.spec.ts")
|
||||
})
|
||||
} as unknown as Libp2pComponents;
|
||||
|
||||
|
@ -5,12 +5,16 @@ import { Protocols } from "@waku/interfaces";
|
||||
import { createRelayNode } from "@waku/sdk/relay";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NOISE_KEY_1, tearDownNodes } from "../src/index.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
|
||||
describe("ENR Interop: NimGoNode", function () {
|
||||
describe("ENR Interop: ServiceNode", function () {
|
||||
let waku: RelayNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(15000);
|
||||
@ -19,7 +23,7 @@ describe("ENR Interop: NimGoNode", function () {
|
||||
|
||||
it("Relay", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
relay: true,
|
||||
store: false,
|
||||
@ -51,7 +55,7 @@ describe("ENR Interop: NimGoNode", function () {
|
||||
|
||||
it("Relay + Store", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
relay: true,
|
||||
store: true,
|
||||
@ -83,7 +87,7 @@ describe("ENR Interop: NimGoNode", function () {
|
||||
|
||||
it("All", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
relay: true,
|
||||
store: true,
|
||||
|
@ -29,9 +29,9 @@ import {
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
NOISE_KEY_2,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
|
||||
const log = new Logger("test:ephemeral");
|
||||
|
||||
@ -43,7 +43,7 @@ const TestDecoder = createDecoder(TestContentTopic);
|
||||
|
||||
describe("Waku Message Ephemeral field", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
let subscription: IFilterSubscription;
|
||||
|
||||
@ -54,7 +54,7 @@ describe("Waku Message Ephemeral field", () => {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
|
@ -18,18 +18,17 @@ import { expect } from "chai";
|
||||
import {
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import { runNodes } from "./utils.js";
|
||||
} from "../../../src/index.js";
|
||||
import { runNodes } from "../utils.js";
|
||||
|
||||
describe("Waku Filter V2: Multiple PubsubTopics", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
@ -121,7 +120,7 @@ describe("Waku Filter V2: Multiple PubsubTopics", function () {
|
||||
await subscription.subscribe([customDecoder1], messageCollector.callback);
|
||||
|
||||
// Set up and start a new nwaku node with customPubsubTopic1
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
@ -185,8 +184,8 @@ describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
@ -295,7 +294,7 @@ describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
|
||||
await subscription.subscribe([customDecoder1], messageCollector.callback);
|
||||
|
||||
// Set up and start a new nwaku node with customPubsubTopic1
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
@ -359,8 +358,8 @@ describe("Waku Filter V2 (Named sharding): Multiple PubsubTopics", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
@ -387,10 +386,14 @@ describe("Waku Filter V2 (Named sharding): Multiple PubsubTopics", function () {
|
||||
|
||||
this.beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
[nwaku, waku] = await runNodes(this, [
|
||||
customPubsubTopic1,
|
||||
customPubsubTopic2
|
||||
]);
|
||||
[nwaku, waku] = await runNodes(
|
||||
this,
|
||||
[customPubsubTopic1, customPubsubTopic2],
|
||||
{
|
||||
clusterId: 3,
|
||||
shards: [1, 2]
|
||||
}
|
||||
);
|
||||
subscription = await waku.filter.createSubscription(customPubsubTopic1);
|
||||
messageCollector = new MessageCollector();
|
||||
});
|
||||
@ -446,7 +449,7 @@ describe("Waku Filter V2 (Named sharding): Multiple PubsubTopics", function () {
|
||||
await subscription.subscribe([customDecoder1], messageCollector.callback);
|
||||
|
||||
// Set up and start a new nwaku node with customPubsubTopic1
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
@ -3,21 +3,24 @@ import type { IFilterSubscription, LightNode } from "@waku/interfaces";
|
||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { MessageCollector, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
|
||||
import {
|
||||
MessageCollector,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../../src/index.js";
|
||||
import {
|
||||
runNodes,
|
||||
TestContentTopic,
|
||||
TestDecoder,
|
||||
TestEncoder,
|
||||
validatePingError
|
||||
} from "./utils.js";
|
||||
} from "../utils.js";
|
||||
|
||||
describe("Waku Filter V2: Ping", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(10000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
@ -8,25 +8,24 @@ import { expect } from "chai";
|
||||
import {
|
||||
delay,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes,
|
||||
TEST_STRING,
|
||||
TEST_TIMESTAMPS
|
||||
} from "../../src/index.js";
|
||||
|
||||
} from "../../../src/index.js";
|
||||
import {
|
||||
messageText,
|
||||
runNodes,
|
||||
TestContentTopic,
|
||||
TestDecoder,
|
||||
TestEncoder
|
||||
} from "./utils.js";
|
||||
} from "../utils.js";
|
||||
|
||||
describe("Waku Filter V2: FilterPush", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(10000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
@ -15,13 +15,13 @@ import { expect } from "chai";
|
||||
import {
|
||||
delay,
|
||||
generateTestData,
|
||||
isNwakuAtLeast,
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes,
|
||||
TEST_STRING
|
||||
} from "../../src/index.js";
|
||||
|
||||
} from "../../../src/index.js";
|
||||
import {
|
||||
messagePayload,
|
||||
messageText,
|
||||
@ -29,14 +29,14 @@ import {
|
||||
TestContentTopic,
|
||||
TestDecoder,
|
||||
TestEncoder
|
||||
} from "./utils.js";
|
||||
} from "../utils.js";
|
||||
|
||||
describe("Waku Filter V2: Subscribe", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(10000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
@ -118,7 +118,7 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||
|
||||
// Send a test message using the relay post method.
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
contentTopic: TestContentTopic,
|
||||
payload: utf8ToBytes(messageText)
|
||||
})
|
||||
@ -220,11 +220,14 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("Subscribe to 30 topics at once and receives messages", async function () {
|
||||
const topicCount = 30;
|
||||
it("Subscribe to 100 topics at once and receives messages", async function () {
|
||||
let topicCount = 30;
|
||||
if (isNwakuAtLeast("0.24.0")) {
|
||||
this.timeout(50000);
|
||||
topicCount = 100;
|
||||
}
|
||||
const td = generateTestData(topicCount);
|
||||
|
||||
// Subscribe to all 30 topics.
|
||||
await subscription.subscribe(td.decoders, messageCollector.callback);
|
||||
|
||||
// Send a unique message on each topic.
|
||||
@ -234,30 +237,42 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||
});
|
||||
}
|
||||
|
||||
// Verify that each message was received on the corresponding topic.
|
||||
expect(await messageCollector.waitForMessages(30)).to.eq(true);
|
||||
td.contentTopics.forEach((topic, index) => {
|
||||
messageCollector.verifyReceivedMessage(index, {
|
||||
expectedContentTopic: topic,
|
||||
expectedMessageText: `Message for Topic ${index + 1}`
|
||||
// Open issue here: https://github.com/waku-org/js-waku/issues/1790
|
||||
// That's why we use the try catch block
|
||||
try {
|
||||
// Verify that each message was received on the corresponding topic.
|
||||
expect(await messageCollector.waitForMessages(topicCount)).to.eq(true);
|
||||
td.contentTopics.forEach((topic, index) => {
|
||||
messageCollector.verifyReceivedMessage(index, {
|
||||
expectedContentTopic: topic,
|
||||
expectedMessageText: `Message for Topic ${index + 1}`
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"This test still fails because of https://github.com/waku-org/js-waku/issues/1790"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("Error when try to subscribe to more than 30 topics", async function () {
|
||||
const topicCount = 31;
|
||||
it("Error when try to subscribe to more than 101 topics", async function () {
|
||||
let topicCount = 31;
|
||||
if (isNwakuAtLeast("0.24.0")) {
|
||||
topicCount = 101;
|
||||
}
|
||||
const td = generateTestData(topicCount);
|
||||
|
||||
// Attempt to subscribe to 31 topics
|
||||
try {
|
||||
await subscription.subscribe(td.decoders, messageCollector.callback);
|
||||
throw new Error(
|
||||
"Subscribe to 31 topics was successful but was expected to fail with a specific error."
|
||||
`Subscribe to ${topicCount} topics was successful but was expected to fail with a specific error.`
|
||||
);
|
||||
} catch (err) {
|
||||
if (
|
||||
err instanceof Error &&
|
||||
err.message.includes("exceeds maximum content topics: 30")
|
||||
err.message.includes(
|
||||
`exceeds maximum content topics: ${topicCount - 1}`
|
||||
)
|
||||
) {
|
||||
return;
|
||||
} else {
|
||||
@ -370,7 +385,7 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||
await subscription.subscribe([TestDecoder], messageCollector.callback);
|
||||
|
||||
// Set up and start a new nwaku node
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
@ -7,10 +7,9 @@ import { expect } from "chai";
|
||||
import {
|
||||
generateTestData,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
} from "../../../src/index.js";
|
||||
import {
|
||||
messagePayload,
|
||||
messageText,
|
||||
@ -18,13 +17,13 @@ import {
|
||||
TestContentTopic,
|
||||
TestDecoder,
|
||||
TestEncoder
|
||||
} from "./utils.js";
|
||||
} from "../utils.js";
|
||||
|
||||
describe("Waku Filter V2: Unsubscribe", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(10000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let subscription: IFilterSubscription;
|
||||
let messageCollector: MessageCollector;
|
||||
|
@ -11,7 +11,7 @@ import { Logger } from "@waku/utils";
|
||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { Context } from "mocha";
|
||||
|
||||
import { makeLogFileName, NimGoNode, NOISE_KEY_1 } from "../../src/index.js";
|
||||
import { makeLogFileName, NOISE_KEY_1, ServiceNode } from "../../src/index.js";
|
||||
|
||||
// Constants for test configuration.
|
||||
export const log = new Logger("test:filter");
|
||||
@ -47,8 +47,8 @@ export async function runNodes(
|
||||
//TODO: change this to use `ShardInfo` instead of `string[]`
|
||||
pubsubTopics: string[],
|
||||
shardInfo?: ShardingParams
|
||||
): Promise<[NimGoNode, LightNode]> {
|
||||
const nwaku = new NimGoNode(makeLogFileName(context));
|
||||
): Promise<[ServiceNode, LightNode]> {
|
||||
const nwaku = new ServiceNode(makeLogFileName(context));
|
||||
|
||||
await nwaku.start(
|
||||
{
|
||||
@ -80,12 +80,22 @@ export async function runNodes(
|
||||
log.error("jswaku node failed to start:", error);
|
||||
}
|
||||
|
||||
if (waku) {
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]);
|
||||
await nwaku.ensureSubscriptions(pubsubTopics);
|
||||
return [nwaku, waku];
|
||||
} else {
|
||||
if (!waku) {
|
||||
throw new Error("Failed to initialize waku");
|
||||
}
|
||||
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]);
|
||||
await nwaku.ensureSubscriptions(pubsubTopics);
|
||||
|
||||
const wakuConnections = waku.libp2p.getConnections();
|
||||
const nwakuPeers = await nwaku.peers();
|
||||
|
||||
if (wakuConnections.length < 1 || nwakuPeers.length < 1) {
|
||||
throw new Error(
|
||||
`Expected at least 1 peer in each node. Got waku connections: ${wakuConnections.length} and nwaku: ${nwakuPeers.length}`
|
||||
);
|
||||
}
|
||||
|
||||
return [nwaku, waku];
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
import type { Connection } from "@libp2p/interface/connection";
|
||||
import type { PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { Peer } from "@libp2p/interface/peer-store";
|
||||
import type { Connection, Peer, PeerStore } from "@libp2p/interface";
|
||||
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
|
||||
import { LightPushCodec, waitForRemotePeer } from "@waku/core";
|
||||
import {
|
||||
@ -19,20 +17,18 @@ import { expect } from "chai";
|
||||
import fc from "fast-check";
|
||||
import Sinon from "sinon";
|
||||
|
||||
import { makeLogFileName } from "../src/log_file.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
import { tearDownNodes } from "../src/teardown.js";
|
||||
import { makeLogFileName, ServiceNode, tearDownNodes } from "../src/index.js";
|
||||
|
||||
describe("getConnectedPeersForProtocolAndShard", function () {
|
||||
let waku: LightNode;
|
||||
let serviceNode1: NimGoNode;
|
||||
let serviceNode2: NimGoNode;
|
||||
let serviceNode1: ServiceNode;
|
||||
let serviceNode2: ServiceNode;
|
||||
const contentTopic = "/test/2/waku-light-push/utf8";
|
||||
|
||||
this.beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
serviceNode1 = new NimGoNode(makeLogFileName(this) + "1");
|
||||
serviceNode2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
serviceNode1 = new ServiceNode(makeLogFileName(this) + "1");
|
||||
serviceNode2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
@ -186,7 +182,7 @@ describe("getConnectedPeersForProtocolAndShard", function () {
|
||||
});
|
||||
|
||||
// and another node in the same cluster cluster as our node
|
||||
const serviceNode2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
const serviceNode2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await serviceNode2.start({
|
||||
discv5Discovery: true,
|
||||
peerExchange: true,
|
||||
@ -374,7 +370,7 @@ describe("getConnectedPeersForProtocolAndShard", function () {
|
||||
});
|
||||
|
||||
// and another node in the same cluster cluster as our node
|
||||
const serviceNode2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
const serviceNode2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await serviceNode2.start({
|
||||
discv5Discovery: true,
|
||||
peerExchange: true,
|
||||
|
@ -9,26 +9,25 @@ import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { expect } from "chai";
|
||||
|
||||
import {
|
||||
generateRandomUint8Array,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes,
|
||||
TEST_STRING
|
||||
} from "../../src/index.js";
|
||||
import { generateRandomUint8Array } from "../../src/random_array.js";
|
||||
|
||||
} from "../../../src/index.js";
|
||||
import {
|
||||
messagePayload,
|
||||
messageText,
|
||||
runNodes,
|
||||
TestContentTopic,
|
||||
TestEncoder
|
||||
} from "./utils.js";
|
||||
} from "../utils.js";
|
||||
|
||||
describe("Waku Light Push", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
this.beforeEach(async function () {
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { createEncoder, waitForRemotePeer } from "@waku/core";
|
||||
import {
|
||||
ContentTopicInfo,
|
||||
@ -18,17 +18,16 @@ import { expect } from "chai";
|
||||
import {
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import { messageText, runNodes } from "./utils.js";
|
||||
} from "../../../src/index.js";
|
||||
import { messageText, runNodes } from "../utils.js";
|
||||
|
||||
describe("Waku Light Push : Multiple PubsubTopics", function () {
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
const customPubsubTopic1 = singleShardInfoToPubsubTopic({
|
||||
clusterId: 3,
|
||||
@ -126,7 +125,7 @@ describe("Waku Light Push : Multiple PubsubTopics", function () {
|
||||
|
||||
it("Light push messages to 2 nwaku nodes each with different pubsubtopics", async function () {
|
||||
// Set up and start a new nwaku node with Default PubsubTopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
@ -180,8 +179,8 @@ describe("Waku Light Push : Multiple PubsubTopics", function () {
|
||||
describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
// When using lightpush, we have to use a cluster id of 1 because that is the default cluster id for autosharding
|
||||
@ -285,7 +284,7 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
|
||||
|
||||
it("Light push messages to 2 nwaku nodes each with different pubsubtopics", async function () {
|
||||
// Set up and start a new nwaku node with Default PubsubTopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
@ -337,8 +336,8 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
|
||||
describe("Waku Light Push (named sharding): Multiple PubsubTopics", function () {
|
||||
this.timeout(30000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
// When using lightpush, we have to use a cluster id of 1 because that is the default cluster id for autosharding
|
||||
@ -438,7 +437,7 @@ describe("Waku Light Push (named sharding): Multiple PubsubTopics", function ()
|
||||
|
||||
it("Light push messages to 2 nwaku nodes each with different pubsubtopics", async function () {
|
||||
// Set up and start a new nwaku node with Default PubsubTopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
@ -8,7 +8,7 @@ import {
|
||||
import { createLightNode, utf8ToBytes } from "@waku/sdk";
|
||||
import { Logger } from "@waku/utils";
|
||||
|
||||
import { makeLogFileName, NimGoNode, NOISE_KEY_1 } from "../../src/index.js";
|
||||
import { makeLogFileName, NOISE_KEY_1, ServiceNode } from "../../src/index.js";
|
||||
|
||||
// Constants for test configuration.
|
||||
export const log = new Logger("test:lightpush");
|
||||
@ -21,8 +21,8 @@ export async function runNodes(
|
||||
context: Mocha.Context,
|
||||
pubsubTopics: string[],
|
||||
shardInfo?: ShardingParams
|
||||
): Promise<[NimGoNode, LightNode]> {
|
||||
const nwaku = new NimGoNode(makeLogFileName(context));
|
||||
): Promise<[ServiceNode, LightNode]> {
|
||||
const nwaku = new ServiceNode(makeLogFileName(context));
|
||||
await nwaku.start(
|
||||
{
|
||||
lightpush: true,
|
||||
|
@ -6,18 +6,21 @@ import { shardInfoToPubsubTopics } from "@waku/utils";
|
||||
import chai, { expect } from "chai";
|
||||
import chaiAsPromised from "chai-as-promised";
|
||||
|
||||
import { delay, tearDownNodes } from "../src/index.js";
|
||||
import { makeLogFileName } from "../src/log_file.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
describe("Metadata Protocol", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
|
||||
beforeEach(function () {
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this) + "1");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CustomEvent } from "@libp2p/interface/events";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerInfo } from "@libp2p/interface/peer-info";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import type { PeerInfo } from "@libp2p/interface";
|
||||
import { CustomEvent } from "@libp2p/interface";
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import type { Waku } from "@waku/interfaces";
|
||||
@ -11,13 +11,13 @@ import Sinon, { SinonSpy, SinonStub } from "sinon";
|
||||
import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
|
||||
describe("multiaddr: dialing", function () {
|
||||
let waku: Waku;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let dialPeerSpy: SinonSpy;
|
||||
let isPeerTopicConfigured: SinonStub;
|
||||
|
||||
@ -56,7 +56,7 @@ describe("multiaddr: dialing", function () {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(10_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start();
|
||||
|
||||
waku = await createLightNode();
|
||||
@ -84,7 +84,6 @@ describe("multiaddr: dialing", function () {
|
||||
new CustomEvent<PeerInfo>("peer:discovery", {
|
||||
detail: {
|
||||
id: peerId,
|
||||
protocols: [],
|
||||
multiaddrs: [multiaddr]
|
||||
}
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { defaultArgs } from "../src/index.js";
|
||||
import { argsToArray } from "../src/node/dockerode.js";
|
||||
import { argsToArray } from "../src/lib/dockerode.js";
|
||||
|
||||
describe("nwaku", () => {
|
||||
it("Correctly serialized arguments", function () {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import tests from "@libp2p/interface-compliance-tests/peer-discovery";
|
||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||
import type { LightNode, PeerInfo } from "@waku/interfaces";
|
||||
@ -10,20 +10,23 @@ import {
|
||||
import { createLightNode, Libp2pComponents } from "@waku/sdk";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { delay } from "../src/delay.js";
|
||||
import { tearDownNodes, waitForRemotePeerWithCodec } from "../src/index.js";
|
||||
import { makeLogFileName } from "../src/log_file.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes,
|
||||
waitForRemotePeerWithCodec
|
||||
} from "../src/index.js";
|
||||
|
||||
describe("Peer Exchange", () => {
|
||||
describe("Locally Run Nodes", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
|
||||
beforeEach(function () {
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
@ -111,12 +114,12 @@ describe("Peer Exchange", () => {
|
||||
this.timeout(55_000);
|
||||
|
||||
let waku: LightNode;
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
});
|
||||
|
||||
tests({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { DecodedMessage, waitForRemotePeer } from "@waku/core";
|
||||
import { DefaultPubsubTopic, Protocols, RelayNode } from "@waku/interfaces";
|
||||
import { createRelayNode } from "@waku/sdk/relay";
|
||||
@ -6,21 +6,22 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { expect } from "chai";
|
||||
|
||||
import {
|
||||
base64ToUtf8,
|
||||
delay,
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
NOISE_KEY_2,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
import { MessageRpcResponse } from "../../src/node/interfaces.js";
|
||||
import { base64ToUtf8, NimGoNode } from "../../src/node/node.js";
|
||||
import { MessageRpcResponse } from "../../src/types.js";
|
||||
|
||||
import { TestContentTopic, TestDecoder, TestEncoder } from "./utils.js";
|
||||
|
||||
describe("Waku Relay, Interop", function () {
|
||||
this.timeout(15000);
|
||||
let waku: RelayNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(30000);
|
||||
@ -29,7 +30,7 @@ describe("Waku Relay, Interop", function () {
|
||||
});
|
||||
await waku.start();
|
||||
|
||||
nwaku = new NimGoNode(this.test?.ctx?.currentTest?.title + "");
|
||||
nwaku = new ServiceNode(this.test?.ctx?.currentTest?.title + "");
|
||||
await nwaku.start({ relay: true });
|
||||
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
@ -89,7 +90,7 @@ describe("Waku Relay, Interop", function () {
|
||||
);
|
||||
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
contentTopic: TestContentTopic,
|
||||
payload: utf8ToBytes(messageText)
|
||||
})
|
||||
@ -105,7 +106,7 @@ describe("Waku Relay, Interop", function () {
|
||||
describe("Two nodes connected to nwaku", function () {
|
||||
let waku1: RelayNode;
|
||||
let waku2: RelayNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
await tearDownNodes(nwaku, [waku1, waku2]);
|
||||
@ -122,7 +123,7 @@ describe("Waku Relay, Interop", function () {
|
||||
}).then((waku) => waku.start().then(() => waku))
|
||||
]);
|
||||
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ relay: true });
|
||||
|
||||
const nwakuMultiaddr = await nwaku.getMultiaddrWithId();
|
||||
|
@ -6,13 +6,13 @@ import { expect } from "chai";
|
||||
|
||||
import {
|
||||
delay,
|
||||
generateRandomUint8Array,
|
||||
MessageCollector,
|
||||
NOISE_KEY_1,
|
||||
NOISE_KEY_2,
|
||||
tearDownNodes,
|
||||
TEST_STRING
|
||||
} from "../../src/index.js";
|
||||
import { generateRandomUint8Array } from "../../src/random_array.js";
|
||||
|
||||
import {
|
||||
log,
|
||||
|
@ -46,7 +46,7 @@ describe("Waku Relay, Subscribe", function () {
|
||||
});
|
||||
await waku1.dial(waku2.libp2p.peerId);
|
||||
log.info("before each hook done");
|
||||
messageCollector = new MessageCollector();
|
||||
messageCollector = new MessageCollector(this.nwaku);
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { bootstrap } from "@libp2p/bootstrap";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
|
||||
import {
|
||||
ContentTopicInfo,
|
||||
@ -16,27 +16,29 @@ import chai, { expect } from "chai";
|
||||
import chaiAsPromised from "chai-as-promised";
|
||||
import Sinon, { SinonSpy } from "sinon";
|
||||
|
||||
import { delay } from "../../src/delay.js";
|
||||
import { makeLogFileName } from "../../src/log_file.js";
|
||||
import { NimGoNode } from "../../src/node/node.js";
|
||||
import { tearDownNodes } from "../../src/teardown.js";
|
||||
import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
describe("Static Sharding: Peer Management", function () {
|
||||
describe("Peer Exchange", function () {
|
||||
let waku: LightNode;
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku3: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let nwaku3: ServiceNode;
|
||||
|
||||
let dialPeerSpy: SinonSpy;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku3 = new NimGoNode(makeLogFileName(this) + "3");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this) + "1");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
nwaku3 = new ServiceNode(makeLogFileName(this) + "3");
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
@ -199,17 +201,17 @@ describe("Autosharding: Peer Management", function () {
|
||||
|
||||
describe("Peer Exchange", function () {
|
||||
let waku: LightNode;
|
||||
let nwaku1: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku3: NimGoNode;
|
||||
let nwaku1: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let nwaku3: ServiceNode;
|
||||
|
||||
let dialPeerSpy: SinonSpy;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku1 = new NimGoNode(makeLogFileName(this) + "1_auto");
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2_auto");
|
||||
nwaku3 = new NimGoNode(makeLogFileName(this) + "3_auto");
|
||||
nwaku1 = new ServiceNode(makeLogFileName(this) + "1_auto");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2_auto");
|
||||
nwaku3 = new ServiceNode(makeLogFileName(this) + "3_auto");
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
|
@ -13,9 +13,11 @@ import {
|
||||
import { singleShardInfoToPubsubTopic } from "@waku/utils";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { tearDownNodes } from "../../src/index.js";
|
||||
import { makeLogFileName } from "../../src/log_file.js";
|
||||
import { NimGoNode } from "../../src/node/node.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
const PubsubTopic1 = singleShardInfoToPubsubTopic({
|
||||
clusterId: 0,
|
||||
@ -34,11 +36,11 @@ const ContentTopic2 = "/myapp/1/latest/proto";
|
||||
|
||||
describe("Static Sharding: Running Nodes", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
});
|
||||
|
||||
@ -109,11 +111,11 @@ describe("Static Sharding: Running Nodes", () => {
|
||||
|
||||
describe("Autosharding: Running Nodes", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
});
|
||||
|
||||
|
@ -4,7 +4,11 @@ import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
import { bytesToUtf8 } from "@waku/utils/bytes";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
customShardedPubsubTopic1,
|
||||
@ -19,11 +23,11 @@ describe("Waku Store, cursor", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let waku2: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
|
@ -2,7 +2,11 @@ import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
import { IMessage, type LightNode } from "@waku/interfaces";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
customDecoder1,
|
||||
@ -15,11 +19,11 @@ import {
|
||||
describe("Waku Store, error handling", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
waku = await startAndConnectLightNode(nwaku);
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
NimGoNode,
|
||||
ServiceNode,
|
||||
tearDownNodes,
|
||||
TEST_STRING
|
||||
} from "../../src/index.js";
|
||||
@ -46,11 +46,11 @@ describe("Waku Store, general", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let waku2: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
@ -82,7 +82,7 @@ describe("Waku Store, general", function () {
|
||||
for (const testItem of TEST_STRING) {
|
||||
expect(
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: utf8ToBytes(testItem["value"]),
|
||||
contentTopic: TestContentTopic
|
||||
}),
|
||||
@ -93,7 +93,7 @@ describe("Waku Store, general", function () {
|
||||
}
|
||||
|
||||
waku = await startAndConnectLightNode(nwaku);
|
||||
const messageCollector = new MessageCollector();
|
||||
const messageCollector = new MessageCollector(nwaku);
|
||||
messageCollector.list = await processQueriedMessages(
|
||||
waku,
|
||||
[TestDecoder],
|
||||
@ -110,14 +110,14 @@ describe("Waku Store, general", function () {
|
||||
|
||||
it("Query generator for multiple messages with multiple decoders", async function () {
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: utf8ToBytes("M1"),
|
||||
contentTopic: TestContentTopic
|
||||
}),
|
||||
DefaultPubsubTopic
|
||||
);
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: utf8ToBytes("M2"),
|
||||
contentTopic: customContentTopic1
|
||||
}),
|
||||
@ -125,7 +125,7 @@ describe("Waku Store, general", function () {
|
||||
);
|
||||
waku = await startAndConnectLightNode(nwaku);
|
||||
|
||||
const messageCollector = new MessageCollector();
|
||||
const messageCollector = new MessageCollector(nwaku);
|
||||
messageCollector.list = await processQueriedMessages(
|
||||
waku,
|
||||
[TestDecoder, secondDecoder],
|
||||
@ -139,7 +139,7 @@ describe("Waku Store, general", function () {
|
||||
for (const testItem of TEST_STRING) {
|
||||
expect(
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: utf8ToBytes(messageText),
|
||||
contentTopic: testItem["value"]
|
||||
}),
|
||||
|
@ -1,13 +1,16 @@
|
||||
import { createDecoder, waitForRemotePeer } from "@waku/core";
|
||||
import type { ContentTopicInfo, IMessage, LightNode } from "@waku/interfaces";
|
||||
import { createLightNode, Protocols } from "@waku/sdk";
|
||||
import { contentTopicToPubsubTopic } from "@waku/utils";
|
||||
import {
|
||||
contentTopicToPubsubTopic,
|
||||
singleShardInfosToShardInfo
|
||||
} from "@waku/utils";
|
||||
import { expect } from "chai";
|
||||
|
||||
import {
|
||||
makeLogFileName,
|
||||
NimGoNode,
|
||||
NOISE_KEY_1,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
@ -32,12 +35,12 @@ import {
|
||||
describe("Waku Store, custom pubsub topic", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
pubsubTopic: [customShardedPubsubTopic1, customShardedPubsubTopic2],
|
||||
@ -122,7 +125,7 @@ describe("Waku Store, custom pubsub topic", function () {
|
||||
this.timeout(10000);
|
||||
|
||||
// Set up and start a new nwaku node with Default Pubsubtopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
store: true,
|
||||
pubsubTopic: [customShardedPubsubTopic2],
|
||||
@ -179,8 +182,8 @@ describe("Waku Store, custom pubsub topic", function () {
|
||||
describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
|
||||
const customContentTopic1 = "/waku/2/content/utf8";
|
||||
const customContentTopic2 = "/myapp/1/latest/proto";
|
||||
@ -210,7 +213,7 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
pubsubTopic: [autoshardingPubsubTopic1, autoshardingPubsubTopic2],
|
||||
@ -284,7 +287,7 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
this.timeout(10000);
|
||||
|
||||
// Set up and start a new nwaku node with Default Pubsubtopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
store: true,
|
||||
pubsubTopic: [autoshardingPubsubTopic2],
|
||||
@ -331,8 +334,8 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku2: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
|
||||
const customDecoder1 = createDecoder(
|
||||
customContentTopic1,
|
||||
@ -345,16 +348,29 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
|
||||
const shardInfo = singleShardInfosToShardInfo([
|
||||
customShardInfo1,
|
||||
customShardInfo2
|
||||
]);
|
||||
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
relay: true,
|
||||
pubsubTopic: [customShardedPubsubTopic1, customShardedPubsubTopic2],
|
||||
relay: true
|
||||
clusterId: shardInfo.clusterId
|
||||
});
|
||||
await nwaku.ensureSubscriptions([
|
||||
customShardedPubsubTopic1,
|
||||
customShardedPubsubTopic2
|
||||
]);
|
||||
|
||||
waku = await startAndConnectLightNode(
|
||||
nwaku,
|
||||
[customShardedPubsubTopic1, customShardedPubsubTopic2],
|
||||
shardInfo
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
@ -369,10 +385,7 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
customContentTopic1,
|
||||
customShardedPubsubTopic1
|
||||
);
|
||||
waku = await startAndConnectLightNode(nwaku, [
|
||||
customShardedPubsubTopic1,
|
||||
customShardedPubsubTopic2
|
||||
]);
|
||||
|
||||
const messages = await processQueriedMessages(
|
||||
waku,
|
||||
[customDecoder1],
|
||||
@ -403,11 +416,6 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
customShardedPubsubTopic2
|
||||
);
|
||||
|
||||
waku = await startAndConnectLightNode(nwaku, [
|
||||
customShardedPubsubTopic1,
|
||||
customShardedPubsubTopic2
|
||||
]);
|
||||
|
||||
const customMessages = await processQueriedMessages(
|
||||
waku,
|
||||
[customDecoder1],
|
||||
@ -435,7 +443,7 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
this.timeout(10000);
|
||||
|
||||
// Set up and start a new nwaku node with Default Pubsubtopic
|
||||
nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
store: true,
|
||||
pubsubTopic: [customShardedPubsubTopic2],
|
||||
@ -458,13 +466,6 @@ describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
customShardedPubsubTopic2
|
||||
);
|
||||
|
||||
waku = await createLightNode({
|
||||
staticNoiseKey: NOISE_KEY_1,
|
||||
pubsubTopics: [customShardedPubsubTopic1, customShardedPubsubTopic2]
|
||||
});
|
||||
await waku.start();
|
||||
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.dial(await nwaku2.getMultiaddrWithId());
|
||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||
|
||||
|
@ -3,7 +3,11 @@ import type { IMessage, LightNode } from "@waku/interfaces";
|
||||
import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
chunkAndReverseArray,
|
||||
@ -17,11 +21,11 @@ import {
|
||||
describe("Waku Store, order", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
|
@ -2,7 +2,11 @@ import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
import type { LightNode } from "@waku/interfaces";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
sendMessages,
|
||||
@ -14,11 +18,11 @@ import {
|
||||
describe("Waku Store, page size", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
|
@ -2,7 +2,11 @@ import { DecodedMessage, PageDirection } from "@waku/core";
|
||||
import type { IMessage, LightNode } from "@waku/interfaces";
|
||||
import { DefaultPubsubTopic } from "@waku/interfaces";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
sendMessages,
|
||||
@ -15,11 +19,11 @@ import {
|
||||
describe("Waku Store, sorting", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
|
@ -1,7 +1,11 @@
|
||||
import type { IMessage, LightNode } from "@waku/interfaces";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||||
import {
|
||||
makeLogFileName,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
adjustDate,
|
||||
@ -13,11 +17,11 @@ import {
|
||||
describe("Waku Store, time filter", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({ store: true, lightpush: true, relay: true });
|
||||
await nwaku.ensureSubscriptions();
|
||||
});
|
||||
@ -42,7 +46,7 @@ describe("Waku Store, time filter", function () {
|
||||
const msgTimestamp = adjustDate(new Date(), msgTime);
|
||||
expect(
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([0]),
|
||||
contentTopic: TestContentTopic,
|
||||
timestamp: msgTimestamp
|
||||
@ -87,7 +91,7 @@ describe("Waku Store, time filter", function () {
|
||||
const msgTimestamp = adjustDate(new Date(), msgTime);
|
||||
expect(
|
||||
await nwaku.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([0]),
|
||||
contentTopic: TestContentTopic,
|
||||
timestamp: msgTimestamp
|
||||
|
@ -17,7 +17,7 @@ import { createLightNode } from "@waku/sdk";
|
||||
import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { delay, NimGoNode, NOISE_KEY_1 } from "../../src";
|
||||
import { delay, NOISE_KEY_1, ServiceNode } from "../../src";
|
||||
|
||||
export const log = new Logger("test:store");
|
||||
|
||||
@ -47,7 +47,7 @@ export const totalMsgs = 20;
|
||||
export const messageText = "Store Push works!";
|
||||
|
||||
export async function sendMessages(
|
||||
instance: NimGoNode,
|
||||
instance: ServiceNode,
|
||||
numMessages: number,
|
||||
contentTopic: string,
|
||||
pubsubTopic: string
|
||||
@ -55,7 +55,7 @@ export async function sendMessages(
|
||||
for (let i = 0; i < numMessages; i++) {
|
||||
expect(
|
||||
await instance.sendMessage(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([i]),
|
||||
contentTopic: contentTopic
|
||||
}),
|
||||
@ -67,14 +67,14 @@ export async function sendMessages(
|
||||
}
|
||||
|
||||
export async function sendMessagesAutosharding(
|
||||
instance: NimGoNode,
|
||||
instance: ServiceNode,
|
||||
numMessages: number,
|
||||
contentTopic: string
|
||||
): Promise<void> {
|
||||
for (let i = 0; i < numMessages; i++) {
|
||||
expect(
|
||||
await instance.sendMessageAutosharding(
|
||||
NimGoNode.toMessageRpcQuery({
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([i]),
|
||||
contentTopic: contentTopic
|
||||
})
|
||||
@ -102,21 +102,32 @@ export async function processQueriedMessages(
|
||||
}
|
||||
|
||||
export async function startAndConnectLightNode(
|
||||
instance: NimGoNode,
|
||||
instance: ServiceNode,
|
||||
pubsubTopics: string[] = [DefaultPubsubTopic],
|
||||
shardInfo?: ShardingParams
|
||||
): Promise<LightNode> {
|
||||
const waku = await createLightNode({
|
||||
pubsubTopics: shardInfo ? undefined : pubsubTopics,
|
||||
staticNoiseKey: NOISE_KEY_1,
|
||||
libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } },
|
||||
...((pubsubTopics.length !== 1 ||
|
||||
pubsubTopics[0] !== DefaultPubsubTopic) && {
|
||||
shardInfo: shardInfo
|
||||
}),
|
||||
pubsubTopics: shardInfo ? undefined : pubsubTopics,
|
||||
staticNoiseKey: NOISE_KEY_1
|
||||
})
|
||||
});
|
||||
await waku.start();
|
||||
await waku.dial(await instance.getMultiaddrWithId());
|
||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||
|
||||
const wakuConnections = waku.libp2p.getConnections();
|
||||
const nwakuPeers = await instance.peers();
|
||||
|
||||
if (wakuConnections.length < 1 || nwakuPeers.length < 1) {
|
||||
throw new Error(
|
||||
`Expected at least 1 peer in each node. Got waku connections: ${wakuConnections.length} and nwaku: ${nwakuPeers.length}`
|
||||
);
|
||||
}
|
||||
|
||||
log.info("Waku node created");
|
||||
return waku;
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
@ -26,11 +26,11 @@ const TestDecoder = createDecoder(TestContentTopic);
|
||||
|
||||
describe("Util: toAsyncIterator: Filter", () => {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(15000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
|
@ -9,14 +9,14 @@ import {
|
||||
delay,
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
|
||||
describe("Wait for remote peer", function () {
|
||||
let waku1: RelayNode;
|
||||
let waku2: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(15000);
|
||||
@ -25,7 +25,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Relay - dialed first", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
relay: true,
|
||||
store: false,
|
||||
@ -50,7 +50,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Relay - dialed after", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
relay: true,
|
||||
store: false,
|
||||
@ -98,7 +98,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Store - dialed first", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
relay: false,
|
||||
@ -126,7 +126,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Store - dialed after - with timeout", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
relay: false,
|
||||
@ -156,7 +156,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("LightPush", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
lightpush: true,
|
||||
filter: false,
|
||||
@ -184,7 +184,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Filter", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
lightpush: false,
|
||||
@ -212,7 +212,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Light Node - default protocols", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
lightpush: true,
|
||||
@ -252,7 +252,7 @@ describe("Wait for remote peer", function () {
|
||||
|
||||
it("Privacy Node - default protocol", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: false,
|
||||
lightpush: false,
|
||||
|
@ -4,11 +4,11 @@ import { LightNode } from "@waku/interfaces";
|
||||
import { createLightNode } from "@waku/sdk";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { makeLogFileName, NimGoNode, tearDownNodes } from "../src/index.js";
|
||||
import { makeLogFileName, ServiceNode, tearDownNodes } from "../src/index.js";
|
||||
|
||||
describe("Use static and several ENR trees for bootstrap", function () {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(15000);
|
||||
@ -18,7 +18,7 @@ describe("Use static and several ENR trees for bootstrap", function () {
|
||||
it("", async function () {
|
||||
this.timeout(10_000);
|
||||
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start();
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { bootstrap } from "@libp2p/bootstrap";
|
||||
import type { PeerId } from "@libp2p/interface/peer-id";
|
||||
import type { PeerId } from "@libp2p/interface";
|
||||
import {
|
||||
DecodedMessage,
|
||||
DefaultUserAgent,
|
||||
@ -24,18 +24,18 @@ import {
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
NOISE_KEY_2,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
} from "../src/index.js";
|
||||
import { NimGoNode } from "../src/node/node.js";
|
||||
|
||||
const TestContentTopic = "/test/1/waku/utf8";
|
||||
|
||||
const TestEncoder = createPlainEncoder({ contentTopic: TestContentTopic });
|
||||
|
||||
describe("Waku Dial [node only]", function () {
|
||||
describe("Interop: NimGoNode", function () {
|
||||
describe("Interop: ServiceNode", function () {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(15000);
|
||||
@ -44,7 +44,7 @@ describe("Waku Dial [node only]", function () {
|
||||
|
||||
it("connects to nwaku", async function () {
|
||||
this.timeout(20_000);
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
store: true,
|
||||
@ -77,7 +77,7 @@ describe("Waku Dial [node only]", function () {
|
||||
expect.fail("uncaughtException", e)
|
||||
);
|
||||
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start({
|
||||
filter: true,
|
||||
store: true,
|
||||
@ -100,7 +100,7 @@ describe("Waku Dial [node only]", function () {
|
||||
|
||||
describe("Bootstrap", function () {
|
||||
let waku: LightNode;
|
||||
let nwaku: NimGoNode;
|
||||
let nwaku: ServiceNode;
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(15000);
|
||||
@ -110,7 +110,7 @@ describe("Waku Dial [node only]", function () {
|
||||
it("Passing an array", async function () {
|
||||
this.timeout(10_000);
|
||||
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start();
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
waku = await createLightNode({
|
||||
@ -133,7 +133,7 @@ describe("Waku Dial [node only]", function () {
|
||||
it("Using a function", async function () {
|
||||
this.timeout(10_000);
|
||||
|
||||
nwaku = new NimGoNode(makeLogFileName(this));
|
||||
nwaku = new ServiceNode(makeLogFileName(this));
|
||||
await nwaku.start();
|
||||
|
||||
const nwakuMa = await nwaku.getMultiaddrWithId();
|
||||
|
@ -80,9 +80,8 @@
|
||||
"@waku/build-utils": "*",
|
||||
"cspell": "^7.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^4.6.0",
|
||||
"fast-check": "^3.14.0"
|
||||
|
||||
"fast-check": "^3.14.0",
|
||||
"rollup": "^4.9.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
@ -2,6 +2,7 @@ import { sha256 } from "@noble/hashes/sha256";
|
||||
import {
|
||||
DefaultPubsubTopic,
|
||||
PubsubTopic,
|
||||
ShardInfo,
|
||||
ShardingParams,
|
||||
SingleShardInfo
|
||||
} from "@waku/interfaces";
|
||||
@ -17,6 +18,26 @@ export const singleShardInfoToPubsubTopic = (
|
||||
return `/waku/2/rs/${shardInfo.clusterId}/${shardInfo.shard}`;
|
||||
};
|
||||
|
||||
export const singleShardInfosToShardInfo = (
|
||||
singleShardInfos: SingleShardInfo[]
|
||||
): ShardInfo => {
|
||||
if (singleShardInfos.length === 0) throw new Error("Invalid shard");
|
||||
|
||||
const clusterIds = singleShardInfos.map((shardInfo) => shardInfo.clusterId);
|
||||
if (new Set(clusterIds).size !== 1) {
|
||||
throw new Error("Passed shard infos have different clusterIds");
|
||||
}
|
||||
|
||||
const shards = singleShardInfos
|
||||
.map((shardInfo) => shardInfo.shard)
|
||||
.filter((shard): shard is number => shard !== undefined);
|
||||
|
||||
return {
|
||||
clusterId: singleShardInfos[0].clusterId,
|
||||
shards
|
||||
};
|
||||
};
|
||||
|
||||
export const shardInfoToPubsubTopics = (
|
||||
shardInfo: ShardingParams
|
||||
): PubsubTopic[] => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { Connection } from "@libp2p/interface/connection";
|
||||
import type { Peer, PeerStore } from "@libp2p/interface/peer-store";
|
||||
import type { ShardingParams } from "@waku/interfaces";
|
||||
import type { Connection, Peer, PeerStore } from "@libp2p/interface";
|
||||
import { ShardingParams } from "@waku/interfaces";
|
||||
|
||||
import { bytesToUtf8 } from "../bytes/index.js";
|
||||
import { decodeRelayShard } from "../common/relay_shard_codec.js";
|
||||
|
Loading…
x
Reference in New Issue
Block a user