Skip to content

Commit

Permalink
fix(tests): relay tests use random port to avoid conflict (#1998)
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS committed Sep 7, 2023
1 parent 1fb13b0 commit b991682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
31 changes: 11 additions & 20 deletions tests/waku_relay/test_wakunode_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ import
stew/byteutils,
stew/shims/net as stewNet,
testutils/unittests,
chronicles,
chronos,
libp2p/crypto/crypto,
libp2p/crypto/secp,
libp2p/peerid,
libp2p/multiaddress,
libp2p/switch,
libp2p/protocols/pubsub/rpc/messages,
libp2p/protocols/pubsub/pubsub,
libp2p/protocols/pubsub/gossipsub,
libp2p/multihash,
secp256k1
libp2p/protocols/pubsub/gossipsub
import
../../waku/waku_core,
../../waku/node/peer_manager,
../../waku/waku_node,
../../waku/waku_relay,
../testlib/testutils,
../testlib/common,
../testlib/wakucore,
../testlib/wakunode

Expand Down Expand Up @@ -238,10 +229,10 @@ suite "WakuNode - Relay":
let
nodeKey1 = generateSecp256k1Key()
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()
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"
contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes()
Expand Down Expand Up @@ -279,10 +270,10 @@ suite "WakuNode - Relay":
let
nodeKey1 = generateSecp256k1Key()
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()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60522))
bindPort = Port(0))
pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes()
Expand Down Expand Up @@ -320,10 +311,10 @@ suite "WakuNode - Relay":
let
nodeKey1 = generateSecp256k1Key()
node1 = newTestWakuNode(nodeKey1, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60530))
bindPort = Port(0))
nodeKey2 = generateSecp256k1Key()
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"
contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes()
Expand Down Expand Up @@ -364,10 +355,10 @@ suite "WakuNode - Relay":
let
nodeKey1 = generateSecp256k1Key()
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()
node2 = newTestWakuNode(nodeKey2, ValidIpAddress.init("0.0.0.0"),
bindPort = Port(60542))
bindPort = Port(0))
pubSubTopic = "test"
contentTopic = ContentTopic("/waku/2/default-content/proto")
payload = "hello world".toBytes()
Expand Down Expand Up @@ -403,9 +394,9 @@ suite "WakuNode - Relay":
asyncTest "Messages are relayed between nodes with multiple transports (websocket and secure Websockets)":
let
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()
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
pubSubTopic = "test"
Expand Down
14 changes: 8 additions & 6 deletions tests/wakunode_rest/test_rest_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import
presto, presto/client as presto_client,
libp2p/crypto/crypto
import
../../../waku/waku_core,
../../../waku/waku_core/message,
../../../waku/waku_core/topics,
../../../waku/waku_core/time,
../../../waku/waku_node,
../../../waku/node/peer_manager,
../../../waku/node/rest/server,
Expand Down Expand Up @@ -146,7 +148,7 @@ procSuite "Waku v2 Rest API - Store":
let node = testWakuNode()
await node.start()

let restPort = Port(58011)
let restPort = Port(58012)
let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet()

Expand Down Expand Up @@ -244,7 +246,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start()
await node.mountRelay()

let restPort = Port(58011)
let restPort = Port(58013)
let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet()

Expand Down Expand Up @@ -318,7 +320,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start()
await node.mountRelay()

let restPort = Port(58011)
let restPort = Port(58014)
let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet()

Expand Down Expand Up @@ -409,7 +411,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start()
await node.mountRelay()

let restPort = Port(58011)
let restPort = Port(58015)
let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet()

Expand Down Expand Up @@ -466,7 +468,7 @@ procSuite "Waku v2 Rest API - Store":
await node.start()
await node.mountRelay()

let restPort = Port(58011)
let restPort = Port(58016)
let restAddress = ValidIpAddress.init("0.0.0.0")
let restServer = RestServerRef.init(restAddress, restPort).tryGet()

Expand Down

0 comments on commit b991682

Please sign in to comment.