Skip to content

Commit 4a8e62a

Browse files
fix: node restart test issue (#2576)
* test_protocol.nim: enhance test reboot and connect - Is not necessary to start the node if the switch object has been already started - Enable an existing "Relay can receive messages after reboot and reconnect" test - Explicit reconnect to peer in "Relay can receive messages after reboot and reconnect" test * tests/waku_relay/utils: avoid starting the proto again in newTestSwitch proc With that, we avoid double start of the protocol. * bump nim-libp2p
1 parent 828583a commit 4a8e62a

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

tests/waku_relay/test_protocol.nim

+12-8
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ suite "Waku Relay":
6060
pubsubTopicSeq = @[pubsubTopic]
6161
wakuMessage = fakeWakuMessage(testMessage, pubsubTopic)
6262

63-
await allFutures(switch.start(), node.start())
63+
await allFutures(switch.start())
6464

6565
remotePeerInfo = switch.peerInfo.toRemotePeerInfo()
6666
peerId = remotePeerInfo.peerId
6767

6868
asyncTeardown:
69-
await allFutures(switch.stop(), node.stop())
69+
await allFutures(switch.stop())
7070

7171
suite "Subscribe":
7272
asyncTest "Publish without Subscription":
@@ -1210,14 +1210,14 @@ suite "Waku Relay":
12101210
await allFutures(otherSwitch.stop(), otherNode.stop())
12111211

12121212
suite "Security and Privacy":
1213-
xasyncTest "Relay can receive messages after reboot and reconnect":
1213+
asyncTest "Relay can receive messages after reboot and reconnect":
12141214
# Given a second node connected to the first one
12151215
let
12161216
otherSwitch = newTestSwitch()
12171217
otherPeerManager = PeerManager.new(otherSwitch)
12181218
otherNode = await newTestWakuRelay(otherSwitch)
12191219

1220-
await allFutures(otherSwitch.start(), otherNode.start())
1220+
await otherSwitch.start()
12211221
let
12221222
otherRemotePeerInfo = otherSwitch.peerInfo.toRemotePeerInfo()
12231223
otherPeerId = otherRemotePeerInfo.peerId
@@ -1239,8 +1239,11 @@ suite "Waku Relay":
12391239
await sleepAsync(500.millis)
12401240

12411241
# Given other node is stopped and restarted
1242-
await allFutures(otherSwitch.stop(), otherNode.stop())
1243-
await allFutures(otherSwitch.start(), otherNode.start())
1242+
await otherSwitch.stop()
1243+
await otherSwitch.start()
1244+
1245+
check await peerManager.connectRelay(otherRemotePeerInfo)
1246+
12441247
# FIXME: Once stopped and started, nodes are not considered connected, nor do they reconnect after running connectRelay, as below
12451248
# check await otherPeerManager.connectRelay(otherRemotePeerInfo)
12461249

@@ -1269,8 +1272,9 @@ suite "Waku Relay":
12691272
(pubsubTopic, msg2) == otherHandlerFuture.read()
12701273

12711274
# Given node is stopped and restarted
1272-
await allFutures(switch.stop(), node.stop())
1273-
await allFutures(switch.start(), node.start())
1275+
await switch.stop()
1276+
await switch.start()
1277+
check await peerManager.connectRelay(otherRemotePeerInfo)
12741278

12751279
# When sending a message from node
12761280
handlerFuture = newPushHandlerFuture()

tests/waku_relay/utils.nim

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ proc noopRawHandler*(): WakuRelayHandler =
1212

1313
proc newTestWakuRelay*(switch = newTestSwitch()): Future[WakuRelay] {.async.} =
1414
let proto = WakuRelay.new(switch).tryGet()
15-
await proto.start()
1615

1716
let protocolMatcher = proc(proto: string): bool {.gcsafe.} =
1817
return proto.startsWith(WakuRelayCodec)

waku/waku_relay/protocol.nim

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const TopicParameters = TopicParams(
6161

6262
# see: https://rfc.vac.dev/spec/29/#gossipsub-v10-parameters
6363
const GossipsubParameters = GossipSubParams.init(
64-
explicit = true,
6564
pruneBackoff = chronos.minutes(1),
6665
unsubscribeBackoff = chronos.seconds(5),
6766
floodPublish = true,

0 commit comments

Comments
 (0)