mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-22 19:00:13 +00:00
de88fd2c53
* implement a logging proxy The logging proxy: - prevents the need to import chronicles (as well as export except toJson), - prevents the need to override `writeValue` or use or import nim-json-seralization elsewhere in the codebase, allowing for sole use of utils/json for de/serialization, - and handles json formatting correctly in chronicles json sinks * Rename logging -> logutils to avoid ambiguity with common names * clean up * add setProperty for JsonRecord, remove nim-json-serialization conflict * Allow specifying textlines and json format separately Not specifying a LogFormat will apply the formatting to both textlines and json sinks. Specifying a LogFormat will apply the formatting to only that sink. * remove unneeded usages of std/json We only need to import utils/json instead of std/json * move serialization from rest/json to utils/json so it can be shared * fix NoColors ambiguity Was causing unit tests to fail on Windows. * Remove nre usage to fix Windows error Windows was erroring with `could not load: pcre64.dll`. Instead of fixing that error, remove the pcre usage :) * Add logutils module doc * Shorten logutils.formatIt for `NBytes` Both json and textlines formatIt were not needed, and could be combined into one formatIt * remove debug integration test config debug output and logformat of json for integration test logs * Use ## module doc to support docgen * bump nim-poseidon2 to export fromBytes Before the changes in this branch, fromBytes was likely being resolved by nim-stew, or other dependency. With the changes in this branch, that dependency was removed and fromBytes could no longer be resolved. By exporting fromBytes from nim-poseidon, the correct resolution is now happening. * fixes to get compiling after rebasing master * Add support for Result types being logged using formatIt
82 lines
2.1 KiB
Nim
82 lines
2.1 KiB
Nim
import std/os
|
|
import std/macros
|
|
import std/httpclient
|
|
import ../ethertest
|
|
import ./codexclient
|
|
import ./nodes
|
|
|
|
export ethertest
|
|
export codexclient
|
|
export nodes
|
|
|
|
template twonodessuite*(name: string, debug1, debug2: bool | string, body) =
|
|
twonodessuite(name, $debug1, $debug2, body)
|
|
|
|
template twonodessuite*(name: string, debug1, debug2: string, body) =
|
|
ethersuite name:
|
|
|
|
var node1 {.inject, used.}: NodeProcess
|
|
var node2 {.inject, used.}: NodeProcess
|
|
var client1 {.inject, used.}: CodexClient
|
|
var client2 {.inject, used.}: CodexClient
|
|
var account1 {.inject, used.}: Address
|
|
var account2 {.inject, used.}: Address
|
|
|
|
let dataDir1 = getTempDir() / "Codex1"
|
|
let dataDir2 = getTempDir() / "Codex2"
|
|
|
|
setup:
|
|
client1 = CodexClient.new("http://localhost:8080/api/codex/v1")
|
|
client2 = CodexClient.new("http://localhost:8081/api/codex/v1")
|
|
account1 = accounts[0]
|
|
account2 = accounts[1]
|
|
|
|
var node1Args = @[
|
|
"--api-port=8080",
|
|
"--data-dir=" & dataDir1,
|
|
"--nat=127.0.0.1",
|
|
"--disc-ip=127.0.0.1",
|
|
"--disc-port=8090",
|
|
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
|
"--persistence",
|
|
"--eth-account=" & $account1
|
|
]
|
|
|
|
if debug1 != "true" and debug1 != "false":
|
|
node1Args.add("--log-level=" & debug1)
|
|
|
|
node1 = startNode(node1Args, debug = debug1)
|
|
node1.waitUntilStarted()
|
|
|
|
let bootstrap = client1.info()["spr"].getStr()
|
|
|
|
var node2Args = @[
|
|
"--api-port=8081",
|
|
"--data-dir=" & dataDir2,
|
|
"--nat=127.0.0.1",
|
|
"--disc-ip=127.0.0.1",
|
|
"--disc-port=8091",
|
|
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
|
"--bootstrap-node=" & bootstrap,
|
|
"--persistence",
|
|
"--eth-account=" & $account2
|
|
]
|
|
|
|
if debug2 != "true" and debug2 != "false":
|
|
node2Args.add("--log-level=" & debug2)
|
|
|
|
node2 = startNode(node2Args, debug = debug2)
|
|
node2.waitUntilStarted()
|
|
|
|
teardown:
|
|
client1.close()
|
|
client2.close()
|
|
|
|
node1.stop()
|
|
node2.stop()
|
|
|
|
removeDir(dataDir1)
|
|
removeDir(dataDir2)
|
|
|
|
body
|