mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-27 23:27:27 +00:00
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
This commit is contained in:
parent
828583adc2
commit
4a8e62ac5e
@ -60,13 +60,13 @@ suite "Waku Relay":
|
|||||||
pubsubTopicSeq = @[pubsubTopic]
|
pubsubTopicSeq = @[pubsubTopic]
|
||||||
wakuMessage = fakeWakuMessage(testMessage, pubsubTopic)
|
wakuMessage = fakeWakuMessage(testMessage, pubsubTopic)
|
||||||
|
|
||||||
await allFutures(switch.start(), node.start())
|
await allFutures(switch.start())
|
||||||
|
|
||||||
remotePeerInfo = switch.peerInfo.toRemotePeerInfo()
|
remotePeerInfo = switch.peerInfo.toRemotePeerInfo()
|
||||||
peerId = remotePeerInfo.peerId
|
peerId = remotePeerInfo.peerId
|
||||||
|
|
||||||
asyncTeardown:
|
asyncTeardown:
|
||||||
await allFutures(switch.stop(), node.stop())
|
await allFutures(switch.stop())
|
||||||
|
|
||||||
suite "Subscribe":
|
suite "Subscribe":
|
||||||
asyncTest "Publish without Subscription":
|
asyncTest "Publish without Subscription":
|
||||||
@ -1210,14 +1210,14 @@ suite "Waku Relay":
|
|||||||
await allFutures(otherSwitch.stop(), otherNode.stop())
|
await allFutures(otherSwitch.stop(), otherNode.stop())
|
||||||
|
|
||||||
suite "Security and Privacy":
|
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
|
# Given a second node connected to the first one
|
||||||
let
|
let
|
||||||
otherSwitch = newTestSwitch()
|
otherSwitch = newTestSwitch()
|
||||||
otherPeerManager = PeerManager.new(otherSwitch)
|
otherPeerManager = PeerManager.new(otherSwitch)
|
||||||
otherNode = await newTestWakuRelay(otherSwitch)
|
otherNode = await newTestWakuRelay(otherSwitch)
|
||||||
|
|
||||||
await allFutures(otherSwitch.start(), otherNode.start())
|
await otherSwitch.start()
|
||||||
let
|
let
|
||||||
otherRemotePeerInfo = otherSwitch.peerInfo.toRemotePeerInfo()
|
otherRemotePeerInfo = otherSwitch.peerInfo.toRemotePeerInfo()
|
||||||
otherPeerId = otherRemotePeerInfo.peerId
|
otherPeerId = otherRemotePeerInfo.peerId
|
||||||
@ -1239,8 +1239,11 @@ suite "Waku Relay":
|
|||||||
await sleepAsync(500.millis)
|
await sleepAsync(500.millis)
|
||||||
|
|
||||||
# Given other node is stopped and restarted
|
# Given other node is stopped and restarted
|
||||||
await allFutures(otherSwitch.stop(), otherNode.stop())
|
await otherSwitch.stop()
|
||||||
await allFutures(otherSwitch.start(), otherNode.start())
|
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
|
# FIXME: Once stopped and started, nodes are not considered connected, nor do they reconnect after running connectRelay, as below
|
||||||
# check await otherPeerManager.connectRelay(otherRemotePeerInfo)
|
# check await otherPeerManager.connectRelay(otherRemotePeerInfo)
|
||||||
|
|
||||||
@ -1269,8 +1272,9 @@ suite "Waku Relay":
|
|||||||
(pubsubTopic, msg2) == otherHandlerFuture.read()
|
(pubsubTopic, msg2) == otherHandlerFuture.read()
|
||||||
|
|
||||||
# Given node is stopped and restarted
|
# Given node is stopped and restarted
|
||||||
await allFutures(switch.stop(), node.stop())
|
await switch.stop()
|
||||||
await allFutures(switch.start(), node.start())
|
await switch.start()
|
||||||
|
check await peerManager.connectRelay(otherRemotePeerInfo)
|
||||||
|
|
||||||
# When sending a message from node
|
# When sending a message from node
|
||||||
handlerFuture = newPushHandlerFuture()
|
handlerFuture = newPushHandlerFuture()
|
||||||
|
@ -12,7 +12,6 @@ proc noopRawHandler*(): WakuRelayHandler =
|
|||||||
|
|
||||||
proc newTestWakuRelay*(switch = newTestSwitch()): Future[WakuRelay] {.async.} =
|
proc newTestWakuRelay*(switch = newTestSwitch()): Future[WakuRelay] {.async.} =
|
||||||
let proto = WakuRelay.new(switch).tryGet()
|
let proto = WakuRelay.new(switch).tryGet()
|
||||||
await proto.start()
|
|
||||||
|
|
||||||
let protocolMatcher = proc(proto: string): bool {.gcsafe.} =
|
let protocolMatcher = proc(proto: string): bool {.gcsafe.} =
|
||||||
return proto.startsWith(WakuRelayCodec)
|
return proto.startsWith(WakuRelayCodec)
|
||||||
|
2
vendor/nim-libp2p
vendored
2
vendor/nim-libp2p
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 09b3e11956459ad4c364b353b7f1067f42267997
|
Subproject commit b30b2656d52ee304bd56f8f8bbf59ab82b658a36
|
@ -61,7 +61,6 @@ const TopicParameters = TopicParams(
|
|||||||
|
|
||||||
# see: https://rfc.vac.dev/spec/29/#gossipsub-v10-parameters
|
# see: https://rfc.vac.dev/spec/29/#gossipsub-v10-parameters
|
||||||
const GossipsubParameters = GossipSubParams.init(
|
const GossipsubParameters = GossipSubParams.init(
|
||||||
explicit = true,
|
|
||||||
pruneBackoff = chronos.minutes(1),
|
pruneBackoff = chronos.minutes(1),
|
||||||
unsubscribeBackoff = chronos.seconds(5),
|
unsubscribeBackoff = chronos.seconds(5),
|
||||||
floodPublish = true,
|
floodPublish = true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user