-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: introduce
preset
option instead of deducing from cluster-id
- Loading branch information
1 parent
c5e23a0
commit 5489bd3
Showing
6 changed files
with
179 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{.used.} | ||
|
||
import std/options, testutils/unittests, chronos | ||
import | ||
../../waku/factory/external_config, | ||
../../waku/factory/internal_config, | ||
../../waku/factory/networks_config | ||
|
||
suite "Waku config": | ||
test "Default preset is TWN": | ||
## Setup | ||
let twnConf = ClusterConf.TheWakuNetworkConf() | ||
|
||
## Given | ||
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default") | ||
|
||
## When | ||
let res = applyPresetConfiguration(preConfig) | ||
assert res.isOk(), $res.error | ||
|
||
## Then | ||
let conf = res.get() | ||
assert conf.maxMessageSize == twnConf.maxMessageSize | ||
assert conf.clusterId == twnConf.clusterId | ||
assert conf.rlnRelay == twnConf.rlnRelay | ||
assert conf.rlnRelayEthContractAddress == twnConf.rlnRelayEthContractAddress | ||
assert conf.rlnRelayDynamic == twnConf.rlnRelayDynamic | ||
assert conf.rlnRelayBandwidthThreshold == twnConf.rlnRelayBandwidthThreshold | ||
assert conf.rlnEpochSizeSec == twnConf.rlnEpochSizeSec | ||
assert conf.rlnRelayUserMessageLimit == twnConf.rlnRelayUserMessageLimit | ||
assert conf.pubsubTopics == twnConf.pubsubTopics | ||
assert conf.discv5Discovery == twnConf.discv5Discovery | ||
assert conf.discv5BootstrapNodes == twnConf.discv5BootstrapNodes | ||
|
||
test "Subscribes to all valid shards in default network": | ||
## Setup | ||
let twnConf = ClusterConf.TheWakuNetworkConf() | ||
|
||
## Given | ||
let shards: seq[uint16] = @[0, 1, 2, 3, 4, 5, 6, 7] | ||
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards) | ||
|
||
## When | ||
let res = applyPresetConfiguration(preConfig) | ||
assert res.isOk(), $res.error | ||
|
||
## Then | ||
let conf = res.get() | ||
assert conf.pubsubTopics == twnConf.pubsubTopics | ||
|
||
test "Subscribes to some valid shards in default network": | ||
## Setup | ||
let twnConf = ClusterConf.TheWakuNetworkConf() | ||
|
||
## Given | ||
let shards: seq[uint16] = @[0, 4, 7] | ||
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards) | ||
|
||
## When | ||
let res = applyPresetConfiguration(preConfig) | ||
assert res.isOk(), $res.error | ||
|
||
## Then | ||
let conf = res.get() | ||
assert conf.pubsubTopics.len() == shards.len() | ||
assert twnConf.pubsubTopics[0] in conf.pubsubTopics | ||
assert twnConf.pubsubTopics[4] in conf.pubsubTopics | ||
assert twnConf.pubsubTopics[7] in conf.pubsubTopics | ||
|
||
test "Subscribes to invalid shards in default network": | ||
## Setup | ||
let twnConf = ClusterConf.TheWakuNetworkConf() | ||
|
||
## Given | ||
let shards: seq[uint16] = @[0, 4, 7, 10] | ||
let preConfig = WakuNodeConf(cmd: noCommand, preset: "default", shards: shards) | ||
|
||
## When | ||
let res = applyPresetConfiguration(preConfig) | ||
|
||
## Then | ||
assert res.isErr(), "Invalid shard was accepted" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters