logos-messaging-nim/tests/test_waku_metadata.nim
Ivan FB 9f68c83fed chore: bump dependencies for v0.36 (#3410)
* properly pass userMessageLimit to OnchainGroupManager
* waku.nimble 2.2.4 Nim compiler
* rm stew/shims/net import
* change ValidIpAddress.init with parseIpAddress
* fix serialize for zerokit
* group_manager: separate if statements
* protocol_types: add encode UInt32 with zeros up to 32 bytes
* windows build: skip libunwind build and rm libunwind.a inlcusion step
* bump nph to overcome the compilation issues with 2.2.x
* bump nim-libp2p to v1.10.1
2025-05-26 21:58:02 +02:00

67 lines
1.6 KiB
Nim

{.used.}
import
std/[options, sequtils, tables],
testutils/unittests,
chronos,
chronicles,
libp2p/switch,
libp2p/peerId,
libp2p/crypto/crypto,
libp2p/multistream,
libp2p/muxers/muxer,
eth/keys,
eth/p2p/discoveryv5/enr
import
waku/
[
waku_node,
waku_core/topics,
node/peer_manager,
discovery/waku_discv5,
waku_metadata,
],
./testlib/wakucore,
./testlib/wakunode
procSuite "Waku Metadata Protocol":
asyncTest "request() returns the supported metadata of the peer":
let clusterId = 10.uint16
let
node1 = newTestWakuNode(
generateSecp256k1Key(),
parseIpAddress("0.0.0.0"),
Port(0),
clusterId = clusterId,
)
node2 = newTestWakuNode(
generateSecp256k1Key(),
parseIpAddress("0.0.0.0"),
Port(0),
clusterId = clusterId,
)
# Start nodes
await allFutures([node1.start(), node2.start()])
node1.topicSubscriptionQueue.emit((kind: PubsubSub, topic: "/waku/2/rs/10/7"))
node1.topicSubscriptionQueue.emit((kind: PubsubSub, topic: "/waku/2/rs/10/6"))
# Create connection
let connOpt = await node2.peerManager.dialPeer(
node1.switch.peerInfo.toRemotePeerInfo(), WakuMetadataCodec
)
require:
connOpt.isSome
# Request metadata
let response1 = await node2.wakuMetadata.request(connOpt.get())
# Check the response or dont even continue
require:
response1.isOk
check:
response1.get().clusterId.get() == clusterId
response1.get().shards == @[uint32(6), uint32(7)]