2020-08-31 03:32:41 +00:00
|
|
|
|
{.used.}
|
|
|
|
|
|
|
|
|
|
import
|
2024-10-28 08:17:46 +00:00
|
|
|
|
std/[sequtils, strutils, net],
|
2022-11-04 09:52:08 +00:00
|
|
|
|
stew/byteutils,
|
|
|
|
|
stew/shims/net as stewNet,
|
2021-03-26 09:52:04 +00:00
|
|
|
|
testutils/unittests,
|
2023-01-26 10:18:30 +00:00
|
|
|
|
chronicles,
|
|
|
|
|
chronos,
|
2020-08-31 03:32:41 +00:00
|
|
|
|
libp2p/crypto/crypto,
|
|
|
|
|
libp2p/crypto/secp,
|
2021-01-25 11:03:52 +00:00
|
|
|
|
libp2p/multiaddress,
|
2020-09-02 03:15:25 +00:00
|
|
|
|
libp2p/switch,
|
2021-03-11 23:42:26 +00:00
|
|
|
|
libp2p/protocols/pubsub/rpc/messages,
|
|
|
|
|
libp2p/protocols/pubsub/pubsub,
|
2021-04-01 09:37:14 +00:00
|
|
|
|
libp2p/protocols/pubsub/gossipsub,
|
2023-02-09 15:59:29 +00:00
|
|
|
|
libp2p/nameresolving/mockresolver,
|
|
|
|
|
eth/p2p/discoveryv5/enr
|
2022-11-04 09:52:08 +00:00
|
|
|
|
import
|
2024-07-05 22:03:38 +00:00
|
|
|
|
waku/[waku_core, waku_node, node/peer_manager, waku_relay, waku_peer_exchange],
|
2023-04-05 14:01:51 +00:00
|
|
|
|
./testlib/wakucore,
|
|
|
|
|
./testlib/wakunode
|
2020-07-29 13:24:01 +00:00
|
|
|
|
|
2023-02-13 10:43:49 +00:00
|
|
|
|
suite "WakuNode":
|
2021-06-29 14:29:04 +00:00
|
|
|
|
asyncTest "Protocol matcher works as expected":
|
|
|
|
|
let
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey1 = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
node1 = newTestWakuNode(nodeKey1, parseIpAddress("0.0.0.0"), Port(61000))
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey2 = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(61002))
|
2024-09-10 21:07:12 +00:00
|
|
|
|
shard = DefaultRelayShard
|
2021-06-29 14:29:04 +00:00
|
|
|
|
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()
|
2024-09-10 21:07:12 +00:00
|
|
|
|
await node1.mountRelay(@[shard])
|
2021-06-29 14:29:04 +00:00
|
|
|
|
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()
|
2024-09-10 21:07:12 +00:00
|
|
|
|
await node2.mountRelay(@[shard])
|
2021-06-29 14:29:04 +00:00
|
|
|
|
node2.wakuRelay.codec = "/vac/waku/relay/2.0.0-beta2"
|
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
# Check that mounted codecs are actually different
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node1.wakuRelay.codec == "/vac/waku/relay/2.0.0"
|
2021-06-29 14:29:04 +00:00
|
|
|
|
node2.wakuRelay.codec == "/vac/waku/relay/2.0.0-beta2"
|
|
|
|
|
|
|
|
|
|
# Now verify that protocol matcher returns `true` and relay works
|
2022-01-10 15:07:35 +00:00
|
|
|
|
await node1.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
2021-06-29 14:29:04 +00:00
|
|
|
|
|
|
|
|
|
var completionFut = newFuture[bool]()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
proc relayHandler(
|
|
|
|
|
topic: PubsubTopic, msg: WakuMessage
|
|
|
|
|
): Future[void] {.async, gcsafe.} =
|
2023-06-06 17:28:47 +00:00
|
|
|
|
check:
|
2024-09-10 21:07:12 +00:00
|
|
|
|
topic == $shard
|
2023-06-06 17:28:47 +00:00
|
|
|
|
msg.contentTopic == contentTopic
|
|
|
|
|
msg.payload == payload
|
2021-06-29 14:29:04 +00:00
|
|
|
|
completionFut.complete(true)
|
|
|
|
|
|
2024-09-10 21:07:12 +00:00
|
|
|
|
node2.subscribe((kind: PubsubSub, topic: $shard), some(relayHandler))
|
2021-06-29 14:29:04 +00:00
|
|
|
|
await sleepAsync(2000.millis)
|
|
|
|
|
|
2024-09-10 21:07:12 +00:00
|
|
|
|
var res = await node1.publish(some($shard), message)
|
2024-01-18 12:49:13 +00:00
|
|
|
|
assert res.isOk(), $res.error
|
|
|
|
|
|
2021-06-29 14:29:04 +00:00
|
|
|
|
await sleepAsync(2000.millis)
|
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
(await completionFut.withTimeout(5.seconds)) == true
|
2022-09-12 12:51:52 +00:00
|
|
|
|
|
|
|
|
|
await allFutures(node1.stop(), node2.stop())
|
2021-01-25 11:03:52 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
asyncTest "resolve and connect to dns multiaddrs":
|
|
|
|
|
let resolver = MockResolver.new()
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
resolver.ipResponses[("localhost", false)] = @["127.0.0.1"]
|
|
|
|
|
|
|
|
|
|
let
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey1 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node1 = newTestWakuNode(
|
|
|
|
|
nodeKey1, parseIpAddress("0.0.0.0"), Port(61020), nameResolver = resolver
|
|
|
|
|
)
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey2 = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(61022))
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
# Construct DNS multiaddr for node2
|
|
|
|
|
let
|
|
|
|
|
node2PeerId = $(node2.switch.peerInfo.peerId)
|
2022-11-03 13:47:56 +00:00
|
|
|
|
node2Dns4Addr = "/dns4/localhost/tcp/61022/p2p/" & node2PeerId
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-09-07 15:31:27 +00:00
|
|
|
|
await node1.mountRelay()
|
|
|
|
|
await node2.mountRelay()
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
await allFutures([node1.start(), node2.start()])
|
|
|
|
|
|
|
|
|
|
await node1.connectToNodes(@[node2Dns4Addr])
|
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
node1.switch.connManager.connCount(node2.switch.peerInfo.peerId) == 1
|
|
|
|
|
|
|
|
|
|
await allFutures([node1.stop(), node2.stop()])
|
|
|
|
|
|
2021-10-12 12:48:48 +00:00
|
|
|
|
asyncTest "Maximum connections can be configured":
|
|
|
|
|
let
|
|
|
|
|
maxConnections = 2
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey1 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node1 = newTestWakuNode(
|
|
|
|
|
nodeKey1,
|
|
|
|
|
parseIpAddress("0.0.0.0"),
|
|
|
|
|
Port(60010),
|
|
|
|
|
maxConnections = maxConnections,
|
|
|
|
|
)
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey2 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(60012))
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey3 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node3 = newTestWakuNode(nodeKey3, parseIpAddress("0.0.0.0"), Port(60013))
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2021-10-12 12:48:48 +00:00
|
|
|
|
check:
|
|
|
|
|
# Sanity check, to verify config was applied
|
|
|
|
|
node1.switch.connManager.inSema.size == maxConnections
|
|
|
|
|
|
|
|
|
|
# Node with connection limit set to 1
|
|
|
|
|
await node1.start()
|
2022-09-07 15:31:27 +00:00
|
|
|
|
await node1.mountRelay()
|
2021-10-12 12:48:48 +00:00
|
|
|
|
|
|
|
|
|
# Remote node 1
|
|
|
|
|
await node2.start()
|
2022-09-07 15:31:27 +00:00
|
|
|
|
await node2.mountRelay()
|
2021-10-12 12:48:48 +00:00
|
|
|
|
|
|
|
|
|
# Remote node 2
|
|
|
|
|
await node3.start()
|
2022-09-07 15:31:27 +00:00
|
|
|
|
await node3.mountRelay()
|
2021-10-12 12:48:48 +00:00
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
|
discard
|
2024-10-29 16:37:07 +00:00
|
|
|
|
await node1.peerManager.connectPeer(node2.switch.peerInfo.toRemotePeerInfo())
|
2021-10-12 12:48:48 +00:00
|
|
|
|
await sleepAsync(3.seconds)
|
2024-03-15 23:08:47 +00:00
|
|
|
|
discard
|
2024-10-29 16:37:07 +00:00
|
|
|
|
await node1.peerManager.connectPeer(node3.switch.peerInfo.toRemotePeerInfo())
|
2021-10-12 12:48:48 +00:00
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
# Verify that only the first connection succeeded
|
2022-01-10 15:07:35 +00:00
|
|
|
|
node1.switch.isConnected(node2.switch.peerInfo.peerId)
|
|
|
|
|
node1.switch.isConnected(node3.switch.peerInfo.peerId) == false
|
2021-10-12 12:48:48 +00:00
|
|
|
|
|
|
|
|
|
await allFutures([node1.stop(), node2.stop(), node3.stop()])
|
2021-11-02 10:29:11 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
asyncTest "Messages fails with wrong key path":
|
2023-04-05 14:01:51 +00:00
|
|
|
|
let nodeKey1 = generateSecp256k1Key()
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2023-04-05 14:01:51 +00:00
|
|
|
|
expect ResultDefect:
|
2021-11-10 12:05:36 +00:00
|
|
|
|
# gibberish
|
2024-03-15 23:08:47 +00:00
|
|
|
|
discard newTestWakuNode(
|
|
|
|
|
nodeKey1,
|
|
|
|
|
parseIpAddress("0.0.0.0"),
|
2023-01-26 10:18:30 +00:00
|
|
|
|
bindPort = Port(61004),
|
|
|
|
|
wsBindPort = Port(8000),
|
|
|
|
|
wssEnabled = true,
|
2024-03-15 23:08:47 +00:00
|
|
|
|
secureKey = "../../waku/node/key_dummy.txt",
|
|
|
|
|
)
|
2021-11-10 12:05:36 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
asyncTest "Peer info updates with correct announced addresses":
|
|
|
|
|
let
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
bindIp = parseIpAddress("0.0.0.0")
|
2022-11-03 13:47:56 +00:00
|
|
|
|
bindPort = Port(61006)
|
2024-10-28 08:17:46 +00:00
|
|
|
|
extIp = some(getPrimaryIPAddr())
|
2022-11-03 13:47:56 +00:00
|
|
|
|
extPort = some(Port(61008))
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node = newTestWakuNode(nodeKey, bindIp, bindPort, extIp, extPort)
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
let
|
|
|
|
|
bindEndpoint = MultiAddress.init(bindIp, tcpProtocol, bindPort)
|
|
|
|
|
announcedEndpoint = MultiAddress.init(extIp.get(), tcpProtocol, extPort.get())
|
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
# Check that underlying peer info contains only bindIp before starting
|
2022-10-28 09:51:46 +00:00
|
|
|
|
node.switch.peerInfo.listenAddrs.len == 1
|
|
|
|
|
node.switch.peerInfo.listenAddrs.contains(bindEndpoint)
|
|
|
|
|
# Underlying peer info has not updated addrs before starting
|
|
|
|
|
node.switch.peerInfo.addrs.len == 0
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
node.announcedAddresses.len == 1
|
|
|
|
|
node.announcedAddresses.contains(announcedEndpoint)
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
await node.start()
|
2021-11-30 09:12:09 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
check:
|
|
|
|
|
node.started
|
2022-10-28 09:51:46 +00:00
|
|
|
|
# Underlying peer info listenAddrs has not changed
|
|
|
|
|
node.switch.peerInfo.listenAddrs.len == 1
|
|
|
|
|
node.switch.peerInfo.listenAddrs.contains(bindEndpoint)
|
|
|
|
|
# Check that underlying peer info is updated with announced address
|
2022-02-16 16:12:09 +00:00
|
|
|
|
node.switch.peerInfo.addrs.len == 1
|
|
|
|
|
node.switch.peerInfo.addrs.contains(announcedEndpoint)
|
2021-11-30 09:12:09 +00:00
|
|
|
|
|
2022-02-16 16:12:09 +00:00
|
|
|
|
await node.stop()
|
2022-02-18 11:10:38 +00:00
|
|
|
|
|
|
|
|
|
asyncTest "Node can use dns4 in announced addresses":
|
|
|
|
|
let
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
bindIp = parseIpAddress("0.0.0.0")
|
2022-11-03 13:47:56 +00:00
|
|
|
|
bindPort = Port(61010)
|
2024-10-28 08:17:46 +00:00
|
|
|
|
extIp = some(getPrimaryIPAddr())
|
2022-11-03 13:47:56 +00:00
|
|
|
|
extPort = some(Port(61012))
|
2022-02-18 11:10:38 +00:00
|
|
|
|
domainName = "example.com"
|
2024-03-15 23:08:47 +00:00
|
|
|
|
expectedDns4Addr =
|
|
|
|
|
MultiAddress.init("/dns4/" & domainName & "/tcp/" & $(extPort.get())).get()
|
2023-04-05 14:01:51 +00:00
|
|
|
|
node = newTestWakuNode(
|
2024-03-15 23:08:47 +00:00
|
|
|
|
nodeKey, bindIp, bindPort, extIp, extPort, dns4DomainName = some(domainName)
|
|
|
|
|
)
|
2022-05-16 10:51:10 +00:00
|
|
|
|
|
2022-02-18 11:10:38 +00:00
|
|
|
|
check:
|
|
|
|
|
node.announcedAddresses.len == 1
|
|
|
|
|
node.announcedAddresses.contains(expectedDns4Addr)
|
2022-10-28 13:12:06 +00:00
|
|
|
|
|
2023-09-27 13:02:24 +00:00
|
|
|
|
asyncTest "Node uses dns4 resolved ip in announced addresses if no extIp is provided":
|
|
|
|
|
let
|
|
|
|
|
nodeKey = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
bindIp = parseIpAddress("0.0.0.0")
|
2023-09-27 13:02:24 +00:00
|
|
|
|
bindPort = Port(0)
|
|
|
|
|
|
|
|
|
|
domainName = "status.im"
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node =
|
|
|
|
|
newTestWakuNode(nodeKey, bindIp, bindPort, dns4DomainName = some(domainName))
|
2023-09-27 13:02:24 +00:00
|
|
|
|
|
|
|
|
|
var ipStr = ""
|
|
|
|
|
var enrIp = node.enr.tryGet("ip", array[4, byte])
|
2024-03-15 23:08:47 +00:00
|
|
|
|
|
2023-09-27 13:02:24 +00:00
|
|
|
|
if enrIp.isSome():
|
2024-03-15 23:08:47 +00:00
|
|
|
|
ipStr &= $ipv4(enrIp.get())
|
|
|
|
|
|
2023-09-27 13:02:24 +00:00
|
|
|
|
# Check that the IP filled is the one received by the DNS lookup
|
|
|
|
|
# As IPs may change, we check that it's not empty, not the 0 IP and not localhost
|
|
|
|
|
check:
|
|
|
|
|
ipStr.len() > 0
|
|
|
|
|
not ipStr.contains("0.0.0.0")
|
|
|
|
|
not ipStr.contains("127.0.0.1")
|
|
|
|
|
|
|
|
|
|
asyncTest "Node creation fails when invalid dns4 address is provided":
|
|
|
|
|
let
|
|
|
|
|
nodeKey = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
bindIp = parseIpAddress("0.0.0.0")
|
2023-09-27 13:02:24 +00:00
|
|
|
|
bindPort = Port(0)
|
|
|
|
|
|
|
|
|
|
inexistentDomain = "thisdomain.doesnot.exist"
|
|
|
|
|
invalidDomain = ""
|
|
|
|
|
expectedError = "Could not resolve IP from DNS: empty response"
|
2024-03-15 23:08:47 +00:00
|
|
|
|
|
2023-09-27 13:02:24 +00:00
|
|
|
|
var inexistentDomainErr, invalidDomainErr: string = ""
|
|
|
|
|
|
|
|
|
|
# Create node with inexistent domain
|
|
|
|
|
try:
|
|
|
|
|
let node = newTestWakuNode(
|
2024-03-15 23:08:47 +00:00
|
|
|
|
nodeKey, bindIp, bindPort, dns4DomainName = some(inexistentDomain)
|
|
|
|
|
)
|
2023-09-27 13:02:24 +00:00
|
|
|
|
except Exception as e:
|
|
|
|
|
inexistentDomainErr = e.msg
|
|
|
|
|
|
|
|
|
|
# Create node with invalid domain
|
|
|
|
|
try:
|
2024-03-15 23:08:47 +00:00
|
|
|
|
let node =
|
|
|
|
|
newTestWakuNode(nodeKey, bindIp, bindPort, dns4DomainName = some(invalidDomain))
|
2023-09-27 13:02:24 +00:00
|
|
|
|
except Exception as e:
|
|
|
|
|
invalidDomainErr = e.msg
|
|
|
|
|
|
|
|
|
|
# Check that exceptions were raised in both cases
|
|
|
|
|
check:
|
|
|
|
|
inexistentDomainErr == expectedError
|
|
|
|
|
invalidDomainErr == expectedError
|
2023-01-26 10:18:30 +00:00
|
|
|
|
|
2022-10-28 13:12:06 +00:00
|
|
|
|
asyncTest "Agent string is set and advertised correctly":
|
|
|
|
|
let
|
|
|
|
|
# custom agent string
|
|
|
|
|
expectedAgentString1 = "node1-agent-string"
|
|
|
|
|
|
|
|
|
|
# bump when updating nim-libp2p
|
|
|
|
|
expectedAgentString2 = "nim-libp2p/0.0.1"
|
|
|
|
|
let
|
|
|
|
|
# node with custom agent string
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey1 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node1 = newTestWakuNode(
|
|
|
|
|
nodeKey1,
|
|
|
|
|
parseIpAddress("0.0.0.0"),
|
|
|
|
|
Port(61014),
|
|
|
|
|
agentString = some(expectedAgentString1),
|
|
|
|
|
)
|
2022-10-28 13:12:06 +00:00
|
|
|
|
|
|
|
|
|
# node with default agent string from libp2p
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey2 = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(61016))
|
2022-10-28 13:12:06 +00:00
|
|
|
|
|
|
|
|
|
await node1.start()
|
|
|
|
|
await node1.mountRelay()
|
|
|
|
|
|
|
|
|
|
await node2.start()
|
|
|
|
|
await node2.mountRelay()
|
|
|
|
|
|
|
|
|
|
await node1.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
|
|
|
|
await node2.connectToNodes(@[node1.switch.peerInfo.toRemotePeerInfo()])
|
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
|
let node1Agent =
|
|
|
|
|
node2.switch.peerStore[AgentBook][node1.switch.peerInfo.toRemotePeerInfo().peerId]
|
|
|
|
|
let node2Agent =
|
|
|
|
|
node1.switch.peerStore[AgentBook][node2.switch.peerInfo.toRemotePeerInfo().peerId]
|
2022-10-28 13:12:06 +00:00
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
node1Agent == expectedAgentString1
|
|
|
|
|
node2Agent == expectedAgentString2
|
|
|
|
|
|
2023-01-26 10:18:30 +00:00
|
|
|
|
await allFutures(node1.stop(), node2.stop())
|
|
|
|
|
|
|
|
|
|
asyncTest "Custom multiaddresses are set and advertised correctly":
|
|
|
|
|
let
|
|
|
|
|
# custom multiaddress
|
|
|
|
|
expectedMultiaddress1 = MultiAddress.init("/ip4/200.200.200.200/tcp/1234").get()
|
|
|
|
|
|
|
|
|
|
# Note: this could have been done with a single node, but it is useful to
|
|
|
|
|
# have two nodes to check that the multiaddress is advertised correctly
|
|
|
|
|
let
|
|
|
|
|
# node with custom multiaddress
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey1 = generateSecp256k1Key()
|
2024-03-15 23:08:47 +00:00
|
|
|
|
node1 = newTestWakuNode(
|
|
|
|
|
nodeKey1,
|
|
|
|
|
parseIpAddress("0.0.0.0"),
|
|
|
|
|
Port(61018),
|
|
|
|
|
extMultiAddrs = @[expectedMultiaddress1],
|
|
|
|
|
)
|
2023-01-26 10:18:30 +00:00
|
|
|
|
|
|
|
|
|
# node with default multiaddress
|
2023-02-13 10:43:49 +00:00
|
|
|
|
nodeKey2 = generateSecp256k1Key()
|
2023-12-14 06:16:39 +00:00
|
|
|
|
node2 = newTestWakuNode(nodeKey2, parseIpAddress("0.0.0.0"), Port(61020))
|
2023-01-26 10:18:30 +00:00
|
|
|
|
|
|
|
|
|
await node1.start()
|
|
|
|
|
await node1.mountRelay()
|
|
|
|
|
|
|
|
|
|
await node2.start()
|
|
|
|
|
await node2.mountRelay()
|
|
|
|
|
|
|
|
|
|
await node1.connectToNodes(@[node2.switch.peerInfo.toRemotePeerInfo()])
|
|
|
|
|
await node2.connectToNodes(@[node1.switch.peerInfo.toRemotePeerInfo()])
|
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
|
let node1MultiAddrs = node2.switch.peerStore[AddressBook][
|
|
|
|
|
node1.switch.peerInfo.toRemotePeerInfo().peerId
|
|
|
|
|
]
|
2023-01-26 10:18:30 +00:00
|
|
|
|
|
|
|
|
|
check:
|
|
|
|
|
node1MultiAddrs.contains(expectedMultiaddress1)
|
|
|
|
|
|
|
|
|
|
await allFutures(node1.stop(), node2.stop())
|