mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-28 23:10:54 +00:00
chore: adding node factory tests (#2524)
This commit is contained in:
parent
8d7eb3a636
commit
a1b3e090e6
@ -81,3 +81,6 @@ import
|
|||||||
./wakunode_rest/test_rest_cors
|
./wakunode_rest/test_rest_cors
|
||||||
|
|
||||||
import ./waku_rln_relay/test_all
|
import ./waku_rln_relay/test_all
|
||||||
|
|
||||||
|
# Node Factory
|
||||||
|
import ./factory/test_node_factory
|
||||||
|
67
tests/factory/test_node_factory.nim
Normal file
67
tests/factory/test_node_factory.nim
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{.used.}
|
||||||
|
|
||||||
|
import
|
||||||
|
testutils/unittests,
|
||||||
|
chronos
|
||||||
|
|
||||||
|
import
|
||||||
|
../testlib/wakunode,
|
||||||
|
../../waku/factory/node_factory,
|
||||||
|
../../waku/waku_node
|
||||||
|
|
||||||
|
suite "Node Factory":
|
||||||
|
test "Set up a node based on default configurations":
|
||||||
|
let conf = defaultTestWakuNodeConf()
|
||||||
|
|
||||||
|
let node = setupNode(conf).valueOr:
|
||||||
|
raiseAssert error
|
||||||
|
|
||||||
|
check:
|
||||||
|
not node.isNil()
|
||||||
|
node.wakuArchive.isNil()
|
||||||
|
node.wakuStore.isNil()
|
||||||
|
node.wakuFilter.isNil()
|
||||||
|
not node.wakuStoreClient.isNil()
|
||||||
|
not node.rendezvous.isNil()
|
||||||
|
|
||||||
|
test "Set up a node with Store enabled":
|
||||||
|
var conf = defaultTestWakuNodeConf()
|
||||||
|
conf.store = true
|
||||||
|
|
||||||
|
let node = setupNode(conf).valueOr:
|
||||||
|
raiseAssert error
|
||||||
|
|
||||||
|
check:
|
||||||
|
not node.isNil()
|
||||||
|
not node.wakuStore.isNil()
|
||||||
|
not node.wakuArchive.isNil()
|
||||||
|
|
||||||
|
test "Set up a node with Filter enabled":
|
||||||
|
var conf = defaultTestWakuNodeConf()
|
||||||
|
conf.filter = true
|
||||||
|
|
||||||
|
let node = setupNode(conf).valueOr:
|
||||||
|
raiseAssert error
|
||||||
|
|
||||||
|
check:
|
||||||
|
not node.isNil()
|
||||||
|
not node.wakuFilter.isNil()
|
||||||
|
|
||||||
|
test "Start a node based on default configurations":
|
||||||
|
let conf = defaultTestWakuNodeConf()
|
||||||
|
|
||||||
|
let node = setupNode(conf).valueOr:
|
||||||
|
raiseAssert error
|
||||||
|
|
||||||
|
assert not node.isNil(), "Node can't be nil"
|
||||||
|
|
||||||
|
let startRes = catch: (waitFor startNode(node, conf))
|
||||||
|
|
||||||
|
assert not startRes.isErr(), "Exception starting node"
|
||||||
|
assert startRes.get().isOk(), "Error starting node " & startRes.get().error
|
||||||
|
|
||||||
|
check:
|
||||||
|
node.started == true
|
||||||
|
|
||||||
|
## Cleanup
|
||||||
|
waitFor node.stop()
|
@ -35,7 +35,8 @@ proc defaultTestWakuNodeConf*(): WakuNodeConf =
|
|||||||
maxMessageSize: "1024 KiB",
|
maxMessageSize: "1024 KiB",
|
||||||
clusterId: 1.uint32,
|
clusterId: 1.uint32,
|
||||||
topics: @["/waku/2/rs/1/0"],
|
topics: @["/waku/2/rs/1/0"],
|
||||||
relay: true
|
relay: true,
|
||||||
|
storeMessageDbUrl: "sqlite://store.sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
proc newTestWakuNode*(nodeKey: crypto.PrivateKey,
|
proc newTestWakuNode*(nodeKey: crypto.PrivateKey,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user