mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 06:23:10 +00:00
* Reserve `networkconfig` name to waku network related settings * Rename cluster conf to network conf A `NetworkConf` is a Waku network configuration. # Conflicts: # tests/factory/test_waku_conf.nim # Conflicts: # tests/factory/test_waku_conf.nim * Improve sharding configuration A smarter data types simplifies the logic. * Fixing tests * fixup! rename to endpointConf * wip: autosharding is a specific configuration state and treat it like it # Conflicts: # waku/factory/external_config.nim * refactor lightpush handler some metrics error reporting were missing # Conflicts: # waku/waku_lightpush/protocol.nim * test_node_factory tests pass * remove warnings * fix tests * Revert eager previous replace-all command * fix up build tools compilation * metadata is used to store cluster id * Mount relay routes in static sharding * Rename activeRelayShards to subscribeShards To make it clearer that these are the shards the node will subscribe to. * Remove unused msg var * Improve error handling * Set autosharding as default, with 1 shard in network Also makes shards to subscribe to all shards in auto sharding, none in static sharding.
100 lines
2.2 KiB
Nim
100 lines
2.2 KiB
Nim
{.used.}
|
|
|
|
import
|
|
testutils/unittests,
|
|
chronicles,
|
|
chronos,
|
|
libp2p/crypto/crypto,
|
|
libp2p/crypto/secp,
|
|
libp2p/multiaddress,
|
|
libp2p/switch
|
|
import ../testlib/wakucore, ../testlib/wakunode
|
|
|
|
include waku/factory/waku, waku/common/enr/typed_record
|
|
|
|
suite "Wakunode2 - Waku":
|
|
test "compilation version should be reported":
|
|
## Given
|
|
let conf = defaultTestWakuConf()
|
|
|
|
let waku = Waku.new(conf).valueOr:
|
|
raiseAssert error
|
|
|
|
## When
|
|
let version = waku.version
|
|
|
|
## Then
|
|
check:
|
|
version == git_version
|
|
|
|
suite "Wakunode2 - Waku initialization":
|
|
test "peer persistence setup should be successfully mounted":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
conf.peerPersistence = true
|
|
|
|
let waku = Waku.new(conf).valueOr:
|
|
raiseAssert error
|
|
|
|
check:
|
|
not waku.node.peerManager.storage.isNil()
|
|
|
|
test "node setup is successful with default configuration":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
|
|
## When
|
|
var waku = Waku.new(conf).valueOr:
|
|
raiseAssert error
|
|
|
|
(waitFor startWaku(addr waku)).isOkOr:
|
|
raiseAssert error
|
|
|
|
## Then
|
|
let node = waku.node
|
|
check:
|
|
not node.isNil()
|
|
node.wakuArchive.isNil()
|
|
node.wakuStore.isNil()
|
|
not node.wakuStoreClient.isNil()
|
|
not node.wakuRendezvous.isNil()
|
|
|
|
## Cleanup
|
|
waitFor waku.stop()
|
|
|
|
test "app properly handles dynamic port configuration":
|
|
## Given
|
|
var conf = defaultTestWakuConf()
|
|
conf.endpointConf.p2pTcpPort = Port(0)
|
|
|
|
## When
|
|
var waku = Waku.new(conf).valueOr:
|
|
raiseAssert error
|
|
|
|
(waitFor startWaku(addr waku)).isOkOr:
|
|
raiseAssert error
|
|
|
|
## Then
|
|
let
|
|
node = waku.node
|
|
typedNodeEnr = node.enr.toTyped()
|
|
|
|
assert typedNodeEnr.isOk(), $typedNodeEnr.error
|
|
let tcpPort = typedNodeEnr.value.tcp()
|
|
assert tcpPort.isSome()
|
|
check tcpPort.get() != 0
|
|
|
|
check:
|
|
# Waku started properly
|
|
not node.isNil()
|
|
node.wakuArchive.isNil()
|
|
node.wakuStore.isNil()
|
|
not node.wakuStoreClient.isNil()
|
|
not node.wakuRendezvous.isNil()
|
|
|
|
# DS structures are updated with dynamic ports
|
|
typedNodeEnr.get().tcp.get() != 0
|
|
|
|
## Cleanup
|
|
waitFor waku.stop()
|