mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-12 15:06:38 +00:00
deploy: 52b741ac11ba63458c5891f25e052f87f63a62f0
This commit is contained in:
parent
cabce8f6c1
commit
7307f37353
@ -8,6 +8,7 @@ This release contains the following:
|
||||
### Changes
|
||||
- Enables db migration for the message store.
|
||||
- The `resume` Nim API eliminates duplicates messages before storing them.
|
||||
- Support for stable version of `relay` protocol, with protocol ID `/vac/waku/relay/2.0.0`
|
||||
|
||||
#### General refactoring
|
||||
#### Docs
|
||||
|
@ -387,6 +387,62 @@ procSuite "WakuNode":
|
||||
await node1.stop()
|
||||
await node2.stop()
|
||||
await node3.stop()
|
||||
|
||||
asyncTest "Protocol matcher works as expected":
|
||||
let
|
||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||
node1 = WakuNode.init(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||
Port(60000))
|
||||
nodeKey2 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||
node2 = WakuNode.init(nodeKey2, ValidIpAddress.init("0.0.0.0"),
|
||||
Port(60002))
|
||||
pubSubTopic = "/waku/2/default-waku/proto"
|
||||
contentTopic = ContentTopic("/waku/2/default-content/proto")
|
||||
payload = "hello world".toBytes()
|
||||
message = WakuMessage(payload: payload, contentTopic: contentTopic)
|
||||
|
||||
# Setup node 1 with stable codec "/vac/waku/relay/2.0.0"
|
||||
|
||||
await node1.start()
|
||||
node1.mountRelay(@[pubSubTopic])
|
||||
node1.wakuRelay.codec = "/vac/waku/relay/2.0.0"
|
||||
|
||||
# Setup node 2 with beta codec "/vac/waku/relay/2.0.0-beta2"
|
||||
|
||||
await node2.start()
|
||||
node2.mountRelay(@[pubSubTopic])
|
||||
node2.wakuRelay.codec = "/vac/waku/relay/2.0.0-beta2"
|
||||
|
||||
check:
|
||||
# Check that mounted codecs are actually different
|
||||
node1.wakuRelay.codec == "/vac/waku/relay/2.0.0"
|
||||
node2.wakuRelay.codec == "/vac/waku/relay/2.0.0-beta2"
|
||||
|
||||
# Now verify that protocol matcher returns `true` and relay works
|
||||
|
||||
await node1.connectToNodes(@[node2.peerInfo])
|
||||
|
||||
var completionFut = newFuture[bool]()
|
||||
proc relayHandler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
let msg = WakuMessage.init(data)
|
||||
if msg.isOk():
|
||||
let val = msg.value()
|
||||
check:
|
||||
topic == pubSubTopic
|
||||
val.contentTopic == contentTopic
|
||||
val.payload == payload
|
||||
completionFut.complete(true)
|
||||
|
||||
node2.subscribe(pubSubTopic, relayHandler)
|
||||
await sleepAsync(2000.millis)
|
||||
|
||||
await node1.publish(pubSubTopic, message)
|
||||
await sleepAsync(2000.millis)
|
||||
|
||||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
await node1.stop()
|
||||
await node2.stop()
|
||||
|
||||
asyncTest "Peer info parses correctly":
|
||||
## This is such an important utility function for wakunode2
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# libtool - Provide generalized library-building support services.
|
||||
# Generated automatically by config.status (libbacktrace) version-unused
|
||||
# Libtool was configured on host fv-az193-612:
|
||||
# Libtool was configured on host fv-az199-877:
|
||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||
#
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||
|
@ -480,7 +480,13 @@ proc mountRelay*(node: WakuNode,
|
||||
|
||||
info "mounting relay", rlnRelayEnabled=rlnRelayEnabled, relayMessages=relayMessages
|
||||
|
||||
node.switch.mount(wakuRelay)
|
||||
proc relayMatch(proto: string): bool {.gcsafe.} =
|
||||
## Matches the WakuRelayCodec with any postfix.
|
||||
## E.g. if WakuRelayCodec is `/vac/waku/relay/2.0.0` it matches:
|
||||
## `/vac/waku/relay/2.0.0`, `/vac/waku/relay/2.0.0-beta2`, `/vac/waku/relay/2.0.0-actualnonsense`
|
||||
return proto.startsWith(WakuRelayCodec)
|
||||
|
||||
node.switch.mount(wakuRelay, relayMatch)
|
||||
|
||||
if not relayMessages:
|
||||
## Some nodes may choose not to have the capability to relay messages (e.g. "light" nodes).
|
||||
|
@ -15,7 +15,7 @@ logScope:
|
||||
topics = "wakurelay"
|
||||
|
||||
const
|
||||
WakuRelayCodec* = "/vac/waku/relay/2.0.0-beta2"
|
||||
WakuRelayCodec* = "/vac/waku/relay/2.0.0"
|
||||
|
||||
type
|
||||
WakuRelay* = ref object of GossipSub
|
||||
|
Loading…
x
Reference in New Issue
Block a user