logos-delivery/tests/node/test_wakunode_restart.nim
Fabiana Cecin ce918b0819
chore: replace Option with Opt (#4035)
* change all usage of std.options.Option[T] to results.Opt[T]
* fix broken apps and examples (to validate refactor)
* removed all std/options code added for libp2p v2 migration
* add broker Opt codec to persistency/backend_comm.nim
* add a readValue overload for Opt[T] in tools/confutils/cli_args.nim
* keep Option where required (Presto, confutils' config_file.nim)
* Change generateRlnProof error handling
* Fix imports
2026-07-16 14:02:17 -03:00

40 lines
1.2 KiB
Nim

{.used.}
import testutils/unittests, chronos, chronicles
import libp2p/switch
import logos_delivery/waku/[waku_node, waku_core, node/peer_manager]
import ../testlib/[wakucore, wakunode, testasync]
suite "WakuNode - restart (#3979)":
asyncTest "start -> stop -> start re-opens the listener promptly":
## A restart must not block on the relay-reconnect backoff.
let
node1 = newTestWakuNode(generateSecp256k1Key())
node2 = newTestWakuNode(generateSecp256k1Key())
(await node1.mountRelay()).isOkOr:
raiseAssert "mountRelay node1: " & error
(await node2.mountRelay()).isOkOr:
raiseAssert "mountRelay node2: " & error
await allFutures(node1.start(), node2.start())
# node1 learns node2 as a relay peer, so a restart triggers reconnectRelayPeers.
await node1.connectToNodes(@[node2.peerInfo.toRemotePeerInfo()])
await node1.stop()
# The restart must complete promptly and yield a usable, listening node.
let startFut = node1.start()
let restarted = await startFut.withTimeout(20.seconds)
if not restarted:
await startFut.cancelAndWait()
check:
restarted
node1.started
node1.switch.peerInfo.listenAddrs.len > 0
await allFutures(node1.stop(), node2.stop())