mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-15 20:03:09 +00:00
Test work as long as hardhat is already running. Hardhat config needs to be moved back to suite-level
50 lines
1.1 KiB
Nim
50 lines
1.1 KiB
Nim
import std/options
|
|
import std/sequtils
|
|
import ./clioption
|
|
import ./nodeconfig
|
|
|
|
export nodeconfig
|
|
export clioption
|
|
|
|
type
|
|
CodexConfig* = ref object of NodeConfig
|
|
numNodes*: int
|
|
cliOptions*: seq[CliOption]
|
|
logTopics*: seq[string]
|
|
|
|
proc nodes*(config: CodexConfig, numNodes: int): CodexConfig =
|
|
if numNodes < 0:
|
|
raise newException(ValueError, "numNodes must be >= 0")
|
|
|
|
var startConfig = config
|
|
startConfig.numNodes = numNodes
|
|
return startConfig
|
|
|
|
proc simulateProofFailuresFor*(
|
|
config: CodexConfig,
|
|
providerIdx: int,
|
|
failEveryNProofs: int
|
|
): CodexConfig =
|
|
|
|
if providerIdx > config.numNodes - 1:
|
|
raise newException(ValueError, "provider index out of bounds")
|
|
|
|
var startConfig = config
|
|
startConfig.cliOptions.add(
|
|
CliOption(
|
|
nodeIdx: some providerIdx,
|
|
key: "--simulate-proof-failures",
|
|
value: $failEveryNProofs
|
|
)
|
|
)
|
|
return startConfig
|
|
|
|
proc withLogTopics*(
|
|
config: CodexConfig,
|
|
topics: varargs[string]
|
|
): CodexConfig =
|
|
|
|
var startConfig = config
|
|
startConfig.logTopics = startConfig.logTopics.concat(@topics)
|
|
return startConfig
|