Skip to content

Commit

Permalink
chore: adding node factory tests (#2524)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Mar 12, 2024
1 parent 8d7eb3a commit a1b3e09
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/all_tests_waku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ import
./wakunode_rest/test_rest_cors

import ./waku_rln_relay/test_all

# Node Factory
import ./factory/test_node_factory
67 changes: 67 additions & 0 deletions tests/factory/test_node_factory.nim
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion tests/testlib/wakunode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ proc defaultTestWakuNodeConf*(): WakuNodeConf =
maxMessageSize: "1024 KiB",
clusterId: 1.uint32,
topics: @["/waku/2/rs/1/0"],
relay: true
relay: true,
storeMessageDbUrl: "sqlite://store.sqlite3"
)

proc newTestWakuNode*(nodeKey: crypto.PrivateKey,
Expand Down

0 comments on commit a1b3e09

Please sign in to comment.