mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-03-28 20:03:08 +00:00
fix compilation issue in test_node_conf.nim
This commit is contained in:
parent
a0f134aadb
commit
4b5f91c0ce
@ -1,11 +1,14 @@
|
||||
{.used.}
|
||||
|
||||
import std/[options, json, strutils], results, stint, testutils/unittests
|
||||
import json_serialization
|
||||
import confutils, confutils/std/net
|
||||
import tools/confutils/cli_args
|
||||
import waku/factory/waku_conf, waku/factory/networks_config
|
||||
import waku/common/logging
|
||||
import json_serialization, confutils, confutils/std/net
|
||||
import
|
||||
tools/confutils/cli_args,
|
||||
waku/api/api_conf,
|
||||
waku/factory/waku_conf,
|
||||
waku/factory/networks_config,
|
||||
waku/factory/conf_builder/conf_builder,
|
||||
waku/common/logging
|
||||
|
||||
# Helper: parse JSON into WakuNodeConf using fieldPairs (same as liblogosdelivery)
|
||||
proc parseWakuNodeConfFromJson(jsonStr: string): Result[WakuNodeConf, string] =
|
||||
@ -75,7 +78,7 @@ suite "WakuNodeConf - mode-driven toWakuConf":
|
||||
## Given
|
||||
var conf = defaultWakuNodeConf().valueOr:
|
||||
raiseAssert error
|
||||
conf.mode = WakuMode.noMode
|
||||
conf.mode = cli_args.WakuMode.noMode
|
||||
conf.relay = true
|
||||
conf.lightpush = false
|
||||
conf.clusterId = 5
|
||||
@ -118,7 +121,7 @@ suite "WakuNodeConf - JSON parsing with fieldPairs":
|
||||
require confRes.isOk()
|
||||
let conf = confRes.get()
|
||||
check:
|
||||
conf.mode == WakuMode.noMode
|
||||
conf.mode == cli_args.WakuMode.noMode
|
||||
conf.clusterId == 0
|
||||
conf.logLevel == logging.LogLevel.INFO
|
||||
|
||||
@ -368,3 +371,60 @@ suite "NodeConfig (deprecated) - toWakuConf":
|
||||
wakuConf.peerExchangeService == true
|
||||
|
||||
{.pop.}
|
||||
|
||||
suite "WakuConfBuilder - store retention policies":
|
||||
test "Multiple retention policies":
|
||||
## Given
|
||||
var b = WakuConfBuilder.init()
|
||||
b.storeServiceConf.withEnabled(true)
|
||||
b.storeServiceConf.withDbUrl("sqlite://test.db")
|
||||
b.storeServiceConf.withRetentionPolicies(
|
||||
"time:86400 ; capacity:10000; size : 50GB"
|
||||
)
|
||||
|
||||
## When
|
||||
let wakuConf = b.build().valueOr:
|
||||
raiseAssert error
|
||||
|
||||
## Then
|
||||
require wakuConf.storeServiceConf.isSome()
|
||||
let storeConf = wakuConf.storeServiceConf.get()
|
||||
check storeConf.retentionPolicies == @["time:86400", "capacity:10000", "size:50GB"]
|
||||
|
||||
test "Duplicated retention policies returns error":
|
||||
## Given
|
||||
var b = WakuConfBuilder.init()
|
||||
b.storeServiceConf.withEnabled(true)
|
||||
b.storeServiceConf.withDbUrl("sqlite://test.db")
|
||||
b.storeServiceConf.withRetentionPolicies("time:86400;time:800;capacity:10000")
|
||||
|
||||
## When
|
||||
let wakuConfRes = b.build()
|
||||
check wakuConfRes.isErr()
|
||||
check wakuConfRes.error.contains("duplicated retention policy type")
|
||||
|
||||
test "Incorrect retention policy type returns error":
|
||||
## Given
|
||||
var b = WakuConfBuilder.init()
|
||||
b.storeServiceConf.withEnabled(true)
|
||||
b.storeServiceConf.withDbUrl("sqlite://test.db")
|
||||
b.storeServiceConf.withRetentionPolicies("capaity:10000")
|
||||
|
||||
## When
|
||||
let wakuConfRes = b.build()
|
||||
|
||||
## Then
|
||||
check wakuConfRes.isErr()
|
||||
check wakuConfRes.error.contains("unknown retention policy type")
|
||||
|
||||
test "Store disabled - no retention policy applied":
|
||||
## Given
|
||||
var b = WakuConfBuilder.init()
|
||||
# storeServiceConf not enabled
|
||||
|
||||
## When
|
||||
let wakuConf = b.build().valueOr:
|
||||
raiseAssert error
|
||||
|
||||
## Then
|
||||
check wakuConf.storeServiceConf.isNone()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user