mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-02 13:53:12 +00:00
Register waku protocol instead of gossip sub
This commit is contained in:
parent
525815528f
commit
12c2a93c7f
@ -4,6 +4,7 @@ import test from 'ava';
|
||||
import Pubsub from 'libp2p-interfaces/src/pubsub';
|
||||
|
||||
import { createNode } from './node';
|
||||
import { CODEC } from './waku_relay';
|
||||
|
||||
function delay(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
@ -34,6 +35,14 @@ test('Can publish message', async (t) => {
|
||||
t.deepEqual(node1Received, message);
|
||||
});
|
||||
|
||||
test('Register waku relay protocol', async (t) => {
|
||||
const node = await createNode();
|
||||
|
||||
const protocols = Array.from(node.upgrader.protocols.keys());
|
||||
|
||||
t.truthy(protocols.findIndex((value) => value == CODEC));
|
||||
});
|
||||
|
||||
function waitForNextData(pubsub: Pubsub, topic: string) {
|
||||
return new Promise((resolve) => {
|
||||
pubsub.once(topic, resolve);
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import Libp2p from 'libp2p';
|
||||
import Gossipsub from 'libp2p-gossipsub';
|
||||
import Mplex from 'libp2p-mplex';
|
||||
import { NOISE } from 'libp2p-noise';
|
||||
import TCP from 'libp2p-tcp';
|
||||
|
||||
import { WakuRelay } from './waku_relay';
|
||||
|
||||
export async function createNode() {
|
||||
const node = await Libp2p.create({
|
||||
addresses: {
|
||||
@ -15,7 +16,7 @@ export async function createNode() {
|
||||
connEncryption: [NOISE],
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Type needs update
|
||||
pubsub: Gossipsub,
|
||||
pubsub: WakuRelay,
|
||||
},
|
||||
config: {
|
||||
pubsub: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user