mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 15:03:07 +00:00
* rework cli to accept circuit params * check circom files extension * adding new required cli changes * don't use ufcs * persistence is a command now * use `nimOldCaseObjects` switch for nim confutils compat * misc * Update cli integration tests * Fix: simulateProofFailures option is not for validator * moving circom params under `prover` command * update tests * Use circuit assets from codex-contract-eth in tests * Add "prover" cli command to tests * use correct stores * make `verifier` a cmd option * update circuit artifacts path * fix cli tests * Update integration tests to use cli commands Integration tests have been updated to use the new cli commands. The api for usage in the integration tests has also changed a bit. Proofs tests have been updated to use 5 nodes and 8 blocks of data. The remaining integration tests also need to be updated. * remove parsedCli from CodexConfig Instead, parse the cli args on the fly when needed * remove unneeded gcsafes * graceful shutdowns Where possible, do not raise assert, as other nodes in the test may already be running. Instead, raise exceptions, catch them in multinodes.nim, and attempt to do a teardown before failing the test. `abortOnError` is set to true so that `fail()` will quit immediately, after teardown has been run. * update testmarketplace to new api, with valid EC params --------- Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com> Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
92 lines
2.3 KiB
Nim
92 lines
2.3 KiB
Nim
import std/osproc
|
|
import std/os
|
|
import std/streams
|
|
import std/strutils
|
|
import pkg/codex/conf
|
|
import pkg/codex/logutils
|
|
import pkg/confutils
|
|
import pkg/libp2p
|
|
import pkg/questionable
|
|
import ./codexclient
|
|
|
|
export codexclient
|
|
|
|
const workingDir = currentSourcePath() / ".." / ".." / ".."
|
|
const executable = "build" / "codex"
|
|
|
|
type
|
|
NodeProcess* = ref object
|
|
process: Process
|
|
arguments: seq[string]
|
|
debug: bool
|
|
client: ?CodexClient
|
|
|
|
proc start(node: NodeProcess) =
|
|
if node.debug:
|
|
node.process = osproc.startProcess(
|
|
executable,
|
|
workingDir,
|
|
node.arguments,
|
|
options={poParentStreams}
|
|
)
|
|
else:
|
|
node.process = osproc.startProcess(
|
|
executable,
|
|
workingDir,
|
|
node.arguments
|
|
)
|
|
|
|
proc waitUntilOutput*(node: NodeProcess, output: string) =
|
|
if node.debug:
|
|
raiseAssert "cannot read node output when in debug mode"
|
|
for line in node.process.outputStream.lines:
|
|
if line.contains(output):
|
|
return
|
|
raiseAssert "node did not output '" & output & "'"
|
|
|
|
proc waitUntilStarted*(node: NodeProcess) =
|
|
if node.debug:
|
|
sleep(5_000)
|
|
else:
|
|
node.waitUntilOutput("Started codex node")
|
|
|
|
proc startNode*(args: openArray[string], debug: string | bool = false): NodeProcess =
|
|
## Starts a Codex Node with the specified arguments.
|
|
## Set debug to 'true' to see output of the node.
|
|
let node = NodeProcess(arguments: @args, debug: ($debug != "false"))
|
|
node.start()
|
|
node
|
|
|
|
proc dataDir(node: NodeProcess): string =
|
|
let config = CodexConf.load(cmdLine = node.arguments, quitOnFailure = false)
|
|
config.dataDir.string
|
|
|
|
proc apiUrl(node: NodeProcess): string =
|
|
let config = CodexConf.load(cmdLine = node.arguments, quitOnFailure = false)
|
|
"http://" & config.apiBindAddress & ":" & $config.apiPort & "/api/codex/v1"
|
|
|
|
proc client*(node: NodeProcess): CodexClient =
|
|
if client =? node.client:
|
|
return client
|
|
let client = CodexClient.new(node.apiUrl)
|
|
node.client = some client
|
|
client
|
|
|
|
proc stop*(node: NodeProcess) =
|
|
if node.process != nil:
|
|
node.process.terminate()
|
|
discard node.process.waitForExit(timeout=5_000)
|
|
node.process.close()
|
|
node.process = nil
|
|
if client =? node.client:
|
|
node.client = none CodexClient
|
|
client.close()
|
|
|
|
proc restart*(node: NodeProcess) =
|
|
node.stop()
|
|
node.start()
|
|
node.waitUntilStarted()
|
|
|
|
proc removeDataDir*(node: NodeProcess) =
|
|
removeDir(node.dataDir)
|