fix(tests): relay tests use random port to avoid conflict (#1998)

This commit is contained in:
Simon-Pierre Vivier 2023-09-07 07:41:56 -04:00 committed by GitHub
parent 1fb13b0967
commit b991682b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 26 deletions

View File

@ -5,25 +5,16 @@ import
stew/byteutils, stew/byteutils,
stew/shims/net as stewNet, stew/shims/net as stewNet,
testutils/unittests, testutils/unittests,
chronicles,
chronos, chronos,
libp2p/crypto/crypto,
libp2p/crypto/secp,
libp2p/peerid,
libp2p/multiaddress,
libp2p/switch, libp2p/switch,
libp2p/protocols/pubsub/rpc/messages,
libp2p/protocols/pubsub/pubsub, libp2p/protocols/pubsub/pubsub,
libp2p/protocols/pubsub/gossipsub, libp2p/protocols/pubsub/gossipsub
libp2p/multihash,
secp256k1
import import
../../waku/waku_core, ../../waku/waku_core,
../../waku/node/peer_manager, ../../waku/node/peer_manager,
../../waku/waku_node, ../../waku/waku_node,
../../waku/waku_relay, ../../waku/waku_relay,
../testlib/testutils, ../testlib/testutils,
../testlib/common,
../testlib/wakucore, ../testlib/wakucore,
../testlib/wakunode ../testlib/wakunode
@ -238,10 +229,10 @@ suite "WakuNode - Relay":
let let
nodeKey1 = generateSecp256k1Key() nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60510), wsBindPort = Port(8001), wsEnabled = true) bindPort = Port(0), wsBindPort = Port(0), wsEnabled = true)
nodeKey2 = generateSecp256k1Key() nodeKey2 = generateSecp256k1Key()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60512), wsBindPort = Port(8101), wsEnabled = true) bindPort = Port(0), wsBindPort = Port(0), wsEnabled = true)
pubSubTopic = "test" pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto") contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes() payload = "hello world".toBytes()
@ -279,10 +270,10 @@ suite "WakuNode - Relay":
let let
nodeKey1 = generateSecp256k1Key() nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60520), wsBindPort = Port(8002), wsEnabled = true) bindPort = Port(0), wsBindPort = Port(0), wsEnabled = true)
nodeKey2 = generateSecp256k1Key() nodeKey2 = generateSecp256k1Key()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60522)) bindPort = Port(0))
pubSubTopic = "test" pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto") contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes() payload = "hello world".toBytes()
@ -320,10 +311,10 @@ suite "WakuNode - Relay":
let let
nodeKey1 = generateSecp256k1Key() nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60530)) bindPort = Port(0))
nodeKey2 = generateSecp256k1Key() nodeKey2 = generateSecp256k1Key()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60532), wsBindPort = Port(8103), wsEnabled = true) bindPort = Port(0), wsBindPort = Port(0), wsEnabled = true)
pubSubTopic = "test" pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto") contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes() payload = "hello world".toBytes()
@ -364,10 +355,10 @@ suite "WakuNode - Relay":
let let
nodeKey1 = generateSecp256k1Key() nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60540), wsBindPort = Port(8004), wssEnabled = true, secureKey = KEY_PATH, secureCert = CERT_PATH) bindPort = Port(0), wsBindPort = Port(0), wssEnabled = true, secureKey = KEY_PATH, secureCert = CERT_PATH)
nodeKey2 = generateSecp256k1Key() nodeKey2 = generateSecp256k1Key()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60542)) bindPort = Port(0))
pubSubTopic = "test" pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto") contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes() payload = "hello world".toBytes()
@ -403,9 +394,9 @@ suite "WakuNode - Relay":
asyncTest "Messages are relayed between nodes with multiple transports (websocket and secure Websockets)": asyncTest "Messages are relayed between nodes with multiple transports (websocket and secure Websockets)":
let let
nodeKey1 = generateSecp256k1Key() nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), bindPort = Port(60550), wsBindPort = Port(8005), wssEnabled = true, secureKey = KEY_PATH, secureCert = CERT_PATH) node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"), bindPort = Port(0), wsBindPort = Port(0), wssEnabled = true, secureKey = KEY_PATH, secureCert = CERT_PATH)
nodeKey2 = generateSecp256k1Key() nodeKey2 = generateSecp256k1Key()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), bindPort = Port(60552),wsBindPort = Port(8105), wsEnabled = true ) node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"), bindPort = Port(0),wsBindPort = Port(0), wsEnabled = true )
let let
pubSubTopic = "test" pubSubTopic = "test"

View File

@ -9,7 +9,9 @@ import
presto, presto/client as presto_client, presto, presto/client as presto_client,
libp2p/crypto/crypto libp2p/crypto/crypto
import import
../../../waku/waku_core, ../../../waku/waku_core/message,
../../../waku/waku_core/topics,
../../../waku/waku_core/time,
../../../waku/waku_node, ../../../waku/waku_node,
../../../waku/node/peer_manager, ../../../waku/node/peer_manager,
../../../waku/node/rest/server, ../../../waku/node/rest/server,
@ -146,7 +148,7 @@ procSuite "Waku v2 Rest API - Store":
let node = testWakuNode() let node = testWakuNode()
await node.start() await node.start()
let restPort = Port(58011) let restPort = Port(58012)
let restAddress = ValidIpAddress.init("0.0.0.0") let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet() let restServer = RestServerRef.init(restAddress, restPort).tryGet()
@ -244,7 +246,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start() await node.start()
await node.mountRelay() await node.mountRelay()
let restPort = Port(58011) let restPort = Port(58013)
let restAddress = ValidIpAddress.init("0.0.0.0") let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet() let restServer = RestServerRef.init(restAddress, restPort).tryGet()
@ -318,7 +320,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start() await node.start()
await node.mountRelay() await node.mountRelay()
let restPort = Port(58011) let restPort = Port(58014)
let restAddress = ValidIpAddress.init("0.0.0.0") let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet() let restServer = RestServerRef.init(restAddress, restPort).tryGet()
@ -409,7 +411,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start() await node.start()
await node.mountRelay() await node.mountRelay()
let restPort = Port(58011) let restPort = Port(58015)
let restAddress = ValidIpAddress.init("0.0.0.0") let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet() let restServer = RestServerRef.init(restAddress, restPort).tryGet()
@ -466,7 +468,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start() await node.start()
await node.mountRelay() await node.mountRelay()
let restPort = Port(58011) let restPort = Port(58016)
let restAddress = ValidIpAddress.init("0.0.0.0") let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet() let restServer = RestServerRef.init(restAddress, restPort).tryGet()