mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-14 11:23:10 +00:00
- removed ethersuite as the base testing suite for multinodesuite because the need to launch hardhat before ethersuite setup and kill hardhat after ethersuite teardown was required. Removing ethersuite allowed for checking if a connection to hardhat was established. If no connection established, hardhat would need to be started via the test config. If there was a connection established, a snapshot is taken during test setup and reverted during teardown. - modified the way the hardhat process was launched, because evaluating a command using chronos startProcess would wait for the command to complete before access to the output stream was given. Instead, we now launch the hardhat executable from node_modules/.bin/hardhat. - modify the way the processes are exited by killing them immediately. - fix warnings
77 lines
1.9 KiB
Nim
77 lines
1.9 KiB
Nim
import pkg/questionable
|
|
import pkg/questionable/results
|
|
import pkg/confutils
|
|
import pkg/chronicles
|
|
import pkg/ethers
|
|
import pkg/libp2p
|
|
import std/os
|
|
import std/strutils
|
|
import codex/conf
|
|
import ./codexclient
|
|
import ./nodeprocess
|
|
|
|
export codexclient
|
|
export chronicles
|
|
export nodeprocess
|
|
|
|
logScope:
|
|
topics = "integration testing codex process"
|
|
|
|
type
|
|
CodexProcess* = ref object of NodeProcess
|
|
client: ?CodexClient
|
|
|
|
method workingDir(node: CodexProcess): string =
|
|
return currentSourcePath() / ".." / ".." / ".."
|
|
|
|
method executable(node: CodexProcess): string =
|
|
return "build" / "codex"
|
|
|
|
method startedOutput(node: CodexProcess): string =
|
|
return "REST service started"
|
|
|
|
method processOptions(node: CodexProcess): set[AsyncProcessOption] =
|
|
return {AsyncProcessOption.StdErrToStdOut}
|
|
|
|
method outputLineEndings(node: CodexProcess): string =
|
|
return "\n"
|
|
|
|
method onOutputLineCaptured(node: CodexProcess, line: string) =
|
|
discard
|
|
|
|
proc dataDir(node: CodexProcess): string =
|
|
let config = CodexConf.load(cmdLine = node.arguments)
|
|
return config.dataDir.string
|
|
|
|
proc ethAccount*(node: CodexProcess): Address =
|
|
let config = CodexConf.load(cmdLine = node.arguments)
|
|
without ethAccount =? config.ethAccount:
|
|
raiseAssert "eth account not set"
|
|
return Address(ethAccount)
|
|
|
|
proc apiUrl*(node: CodexProcess): string =
|
|
let config = CodexConf.load(cmdLine = node.arguments)
|
|
return "http://" & config.apiBindAddress & ":" & $config.apiPort & "/api/codex/v1"
|
|
|
|
proc client*(node: CodexProcess): CodexClient =
|
|
if client =? node.client:
|
|
return client
|
|
let client = CodexClient.new(node.apiUrl)
|
|
node.client = some client
|
|
return client
|
|
|
|
method stop*(node: CodexProcess) {.async.} =
|
|
logScope:
|
|
nodeName = node.name
|
|
|
|
await procCall NodeProcess(node).stop()
|
|
|
|
trace "stopping codex client"
|
|
if client =? node.client:
|
|
client.close()
|
|
node.client = none CodexClient
|
|
|
|
method removeDataDir*(node: CodexProcess) =
|
|
removeDir(node.dataDir)
|
|
|