2023-04-25 13:34:57 +00:00
|
|
|
{.used.}
|
|
|
|
|
|
|
|
import
|
|
|
|
stew/shims/net,
|
|
|
|
testutils/unittests,
|
|
|
|
chronicles,
|
|
|
|
chronos,
|
|
|
|
libp2p/crypto/crypto,
|
|
|
|
libp2p/crypto/secp,
|
|
|
|
libp2p/multiaddress,
|
|
|
|
libp2p/switch
|
2024-05-16 20:29:11 +00:00
|
|
|
import
|
|
|
|
../testlib/common,
|
|
|
|
../testlib/wakucore,
|
|
|
|
../testlib/wakunode,
|
|
|
|
../../waku/node/waku_metrics
|
2023-10-27 07:11:47 +00:00
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
include ../../waku/factory/waku
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
suite "Wakunode2 - Waku":
|
2023-04-25 13:34:57 +00:00
|
|
|
test "compilation version should be reported":
|
|
|
|
## Given
|
|
|
|
let conf = defaultTestWakuNodeConf()
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
let waku = Waku.init(conf).valueOr:
|
2024-03-15 23:08:47 +00:00
|
|
|
raiseAssert error
|
2023-04-25 13:34:57 +00:00
|
|
|
|
|
|
|
## When
|
2024-05-03 12:07:15 +00:00
|
|
|
let version = waku.version
|
2023-04-25 13:34:57 +00:00
|
|
|
|
|
|
|
## Then
|
|
|
|
check:
|
2023-10-27 07:11:47 +00:00
|
|
|
version == git_version
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
suite "Wakunode2 - Waku initialization":
|
2023-04-25 13:34:57 +00:00
|
|
|
test "peer persistence setup should be successfully mounted":
|
|
|
|
## Given
|
|
|
|
var conf = defaultTestWakuNodeConf()
|
|
|
|
conf.peerPersistence = true
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
let waku = Waku.init(conf).valueOr:
|
2024-03-15 23:08:47 +00:00
|
|
|
raiseAssert error
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2024-03-08 22:46:42 +00:00
|
|
|
check:
|
2024-05-03 12:07:15 +00:00
|
|
|
not waku.node.peerManager.storage.isNil()
|
2023-04-25 13:34:57 +00:00
|
|
|
|
|
|
|
test "node setup is successful with default configuration":
|
|
|
|
## Given
|
|
|
|
let conf = defaultTestWakuNodeConf()
|
|
|
|
|
|
|
|
## When
|
2024-05-03 12:07:15 +00:00
|
|
|
var waku = Waku.init(conf).valueOr:
|
2024-03-08 22:46:42 +00:00
|
|
|
raiseAssert error
|
2023-11-21 20:15:39 +00:00
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
(waitFor startWaku(addr waku)).isOkOr:
|
2024-03-08 22:46:42 +00:00
|
|
|
raiseAssert error
|
2023-11-21 20:15:39 +00:00
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
waku.metricsServer = waku_metrics.startMetricsServerAndLogging(conf).valueOr:
|
2024-04-30 13:07:17 +00:00
|
|
|
raiseAssert error
|
2023-11-21 20:15:39 +00:00
|
|
|
|
2023-04-25 13:34:57 +00:00
|
|
|
## Then
|
2024-05-03 12:07:15 +00:00
|
|
|
let node = waku.node
|
2023-04-25 13:34:57 +00:00
|
|
|
check:
|
|
|
|
not node.isNil()
|
|
|
|
node.wakuArchive.isNil()
|
|
|
|
node.wakuStore.isNil()
|
|
|
|
not node.wakuStoreClient.isNil()
|
2023-06-01 19:43:10 +00:00
|
|
|
not node.rendezvous.isNil()
|
2023-04-25 13:34:57 +00:00
|
|
|
|
|
|
|
## Cleanup
|
2024-05-03 12:07:15 +00:00
|
|
|
waitFor waku.stop()
|
2023-10-27 07:11:47 +00:00
|
|
|
|
|
|
|
test "app properly handles dynamic port configuration":
|
|
|
|
## Given
|
|
|
|
var conf = defaultTestWakuNodeConf()
|
|
|
|
conf.tcpPort = Port(0)
|
|
|
|
|
|
|
|
## When
|
2024-05-03 12:07:15 +00:00
|
|
|
var waku = Waku.init(conf).valueOr:
|
2024-03-08 22:46:42 +00:00
|
|
|
raiseAssert error
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
(waitFor startWaku(addr waku)).isOkOr:
|
2024-03-08 22:46:42 +00:00
|
|
|
raiseAssert error
|
2023-10-27 07:11:47 +00:00
|
|
|
|
|
|
|
## Then
|
2024-03-15 23:08:47 +00:00
|
|
|
let
|
2024-05-03 12:07:15 +00:00
|
|
|
node = waku.node
|
2023-10-27 07:11:47 +00:00
|
|
|
typedNodeEnr = node.enr.toTypedRecord()
|
|
|
|
|
|
|
|
assert typedNodeEnr.isOk(), $typedNodeEnr.error
|
|
|
|
|
|
|
|
check:
|
2024-05-03 12:07:15 +00:00
|
|
|
# Waku started properly
|
2023-10-27 07:11:47 +00:00
|
|
|
not node.isNil()
|
|
|
|
node.wakuArchive.isNil()
|
|
|
|
node.wakuStore.isNil()
|
|
|
|
not node.wakuStoreClient.isNil()
|
|
|
|
not node.rendezvous.isNil()
|
|
|
|
|
|
|
|
# DS structures are updated with dynamic ports
|
|
|
|
typedNodeEnr.get().tcp.get() != 0
|
|
|
|
|
|
|
|
## Cleanup
|
2024-05-03 12:07:15 +00:00
|
|
|
waitFor waku.stop()
|