From 4a8e62ac5efd603bcf2a93fcef9e37d1d98cabbe Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:20:39 +0200 Subject: [PATCH] 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 --- tests/waku_relay/test_protocol.nim | 20 ++++++++++++-------- tests/waku_relay/utils.nim | 1 - vendor/nim-libp2p | 2 +- waku/waku_relay/protocol.nim | 1 - 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/waku_relay/test_protocol.nim b/tests/waku_relay/test_protocol.nim index addbf77f1..410528c2a 100644 --- a/tests/waku_relay/test_protocol.nim +++ b/tests/waku_relay/test_protocol.nim @@ -60,13 +60,13 @@ suite "Waku Relay": pubsubTopicSeq = @[pubsubTopic] wakuMessage = fakeWakuMessage(testMessage, pubsubTopic) - await allFutures(switch.start(), node.start()) + await allFutures(switch.start()) remotePeerInfo = switch.peerInfo.toRemotePeerInfo() peerId = remotePeerInfo.peerId asyncTeardown: - await allFutures(switch.stop(), node.stop()) + await allFutures(switch.stop()) suite "Subscribe": asyncTest "Publish without Subscription": @@ -1210,14 +1210,14 @@ suite "Waku Relay": await allFutures(otherSwitch.stop(), otherNode.stop()) suite "Security and Privacy": - xasyncTest "Relay can receive messages after reboot and reconnect": + asyncTest "Relay can receive messages after reboot and reconnect": # Given a second node connected to the first one let otherSwitch = newTestSwitch() otherPeerManager = PeerManager.new(otherSwitch) otherNode = await newTestWakuRelay(otherSwitch) - await allFutures(otherSwitch.start(), otherNode.start()) + await otherSwitch.start() let otherRemotePeerInfo = otherSwitch.peerInfo.toRemotePeerInfo() otherPeerId = otherRemotePeerInfo.peerId @@ -1239,8 +1239,11 @@ suite "Waku Relay": await sleepAsync(500.millis) # Given other node is stopped and restarted - await allFutures(otherSwitch.stop(), otherNode.stop()) - await allFutures(otherSwitch.start(), otherNode.start()) + await otherSwitch.stop() + await otherSwitch.start() + + check await peerManager.connectRelay(otherRemotePeerInfo) + # FIXME: Once stopped and started, nodes are not considered connected, nor do they reconnect after running connectRelay, as below # check await otherPeerManager.connectRelay(otherRemotePeerInfo) @@ -1269,8 +1272,9 @@ suite "Waku Relay": (pubsubTopic, msg2) == otherHandlerFuture.read() # Given node is stopped and restarted - await allFutures(switch.stop(), node.stop()) - await allFutures(switch.start(), node.start()) + await switch.stop() + await switch.start() + check await peerManager.connectRelay(otherRemotePeerInfo) # When sending a message from node handlerFuture = newPushHandlerFuture() diff --git a/tests/waku_relay/utils.nim b/tests/waku_relay/utils.nim index 3bdb1d43f..d1fed6437 100644 --- a/tests/waku_relay/utils.nim +++ b/tests/waku_relay/utils.nim @@ -12,7 +12,6 @@ proc noopRawHandler*(): WakuRelayHandler = proc newTestWakuRelay*(switch = newTestSwitch()): Future[WakuRelay] {.async.} = let proto = WakuRelay.new(switch).tryGet() - await proto.start() let protocolMatcher = proc(proto: string): bool {.gcsafe.} = return proto.startsWith(WakuRelayCodec) diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 09b3e1195..b30b2656d 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 09b3e11956459ad4c364b353b7f1067f42267997 +Subproject commit b30b2656d52ee304bd56f8f8bbf59ab82b658a36 diff --git a/waku/waku_relay/protocol.nim b/waku/waku_relay/protocol.nim index 62f3be0b6..b2aa6bb5e 100644 --- a/waku/waku_relay/protocol.nim +++ b/waku/waku_relay/protocol.nim @@ -61,7 +61,6 @@ const TopicParameters = TopicParams( # see: https://rfc.vac.dev/spec/29/#gossipsub-v10-parameters const GossipsubParameters = GossipSubParams.init( - explicit = true, pruneBackoff = chronos.minutes(1), unsubscribeBackoff = chronos.seconds(5), floodPublish = true,