test: include all factory tests (#3467)

* test: include all factory tests

* test: don't expect to override a preset
This commit is contained in:
fryorcraken 2025-06-25 13:58:49 +10:00 committed by GitHub
parent d7a3a85db9
commit 15025fe6cc
3 changed files with 14 additions and 10 deletions

View File

@ -108,4 +108,4 @@ import
import ./waku_rln_relay/test_all
# Node Factory
import ./factory/test_external_config
import ./factory/[test_external_config, test_node_factory, test_waku_conf]

View File

@ -9,7 +9,7 @@ import
testutils/unittests
import
waku/factory/waku_conf,
waku/factory/waku_conf_builder,
waku/factory/conf_builder/conf_builder,
waku/factory/networks_config,
waku/common/utils/parse_size_units
@ -24,7 +24,7 @@ suite "Waku Conf - build with cluster conf":
let expectedShards = toSeq[0.uint16 .. 7.uint16]
## Given
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
builder.withClusterConf(clusterConf)
builder.withRelay(true)
builder.rlnRelayConf.withTreePath("/tmp/test-tree-path")
@ -65,7 +65,7 @@ suite "Waku Conf - build with cluster conf":
let expectedShards = toSeq[0.uint16 .. 7.uint16]
## Given
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
builder.withClusterConf(clusterConf)
builder.withRelay(false)
@ -95,7 +95,7 @@ suite "Waku Conf - build with cluster conf":
expectedShards = toSeq[0.uint16 .. 7.uint16]
## Given
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
builder.withClusterConf(clusterConf)
builder.rlnRelayConf.withEnabled(false)
@ -122,7 +122,7 @@ suite "Waku Conf - build with cluster conf":
let shards = @[2.uint16, 3.uint16]
## Given
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
builder.withClusterConf(clusterConf)
builder.withShards(shards)
@ -148,7 +148,7 @@ suite "Waku Conf - build with cluster conf":
let shards = @[2.uint16, 10.uint16]
## Given
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
builder.withClusterConf(clusterConf)
builder.withShards(shards)
@ -158,11 +158,11 @@ suite "Waku Conf - build with cluster conf":
## Then
assert resConf.isErr(), "Invalid shard was accepted"
test "Cluster Conf is passed and RLN contract is overridden":
test "Cluster Conf is passed and RLN contract is **not** overridden":
## Setup
let clusterConf = ClusterConf.TheWakuNetworkConf()
var builder = WakuConfBuilder.init()
builder.rlnRelayConf.withEthClientAddress("https://my_eth_rpc_url/")
builder.rlnRelayConf.withEthClientUrls(@["https://my_eth_rpc_url/"])
# Mount all shards in network
let expectedShards = toSeq[0.uint16 .. 7.uint16]
@ -194,7 +194,8 @@ suite "Waku Conf - build with cluster conf":
assert conf.rlnRelayConf.isSome
let rlnRelayConf = conf.rlnRelayConf.get()
check rlnRelayConf.ethContractAddress.string == contractAddress
check rlnRelayConf.ethContractAddress.string ==
clusterConf.rlnRelayEthContractAddress
check rlnRelayConf.dynamic == clusterConf.rlnRelayDynamic
check rlnRelayConf.chainId == clusterConf.rlnRelayChainId
check rlnRelayConf.epochSizeSec == clusterConf.rlnEpochSizeSec

View File

@ -38,6 +38,9 @@ proc withTableIpLimit*(b: var Discv5ConfBuilder, tableIpLimit: uint) =
proc withUdpPort*(b: var Discv5ConfBuilder, udpPort: Port) =
b.udpPort = some(udpPort)
proc withUdpPort*(b: var Discv5ConfBuilder, udpPort: uint) =
b.udpPort = some(Port(udpPort.uint16))
proc withBootstrapNodes*(b: var Discv5ConfBuilder, bootstrapNodes: seq[string]) =
# TODO: validate ENRs?
b.bootstrapNodes = concat(b.bootstrapNodes, bootstrapNodes)