2023-03-27 13:47:25 +00:00
|
|
|
import std/os
|
|
|
|
import std/macros
|
|
|
|
import std/httpclient
|
|
|
|
import ../ethertest
|
|
|
|
import ./codexclient
|
|
|
|
import ./nodes
|
|
|
|
|
|
|
|
export ethertest
|
|
|
|
export codexclient
|
|
|
|
export nodes
|
|
|
|
|
2023-05-15 07:02:57 +00:00
|
|
|
template twonodessuite*(name: string, debug1, debug2: bool | string, body) =
|
|
|
|
twonodessuite(name, $debug1, $debug2, body)
|
|
|
|
|
|
|
|
template twonodessuite*(name: string, debug1, debug2: string, body) =
|
2023-03-27 13:47:25 +00:00
|
|
|
ethersuite name:
|
|
|
|
|
|
|
|
var node1 {.inject, used.}: NodeProcess
|
|
|
|
var node2 {.inject, used.}: NodeProcess
|
|
|
|
var client1 {.inject, used.}: CodexClient
|
|
|
|
var client2 {.inject, used.}: CodexClient
|
2023-05-15 07:02:57 +00:00
|
|
|
var account1 {.inject, used.}: Address
|
|
|
|
var account2 {.inject, used.}: Address
|
2023-03-27 13:47:25 +00:00
|
|
|
|
|
|
|
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")
|
2023-05-15 07:02:57 +00:00
|
|
|
account1 = accounts[0]
|
|
|
|
account2 = accounts[1]
|
2023-03-27 13:47:25 +00:00
|
|
|
|
2023-05-15 07:02:57 +00:00
|
|
|
var node1Args = @[
|
2023-03-27 13:47:25 +00:00
|
|
|
"--api-port=8080",
|
|
|
|
"--data-dir=" & dataDir1,
|
|
|
|
"--nat=127.0.0.1",
|
|
|
|
"--disc-ip=127.0.0.1",
|
|
|
|
"--disc-port=8090",
|
2023-10-24 14:52:06 +00:00
|
|
|
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
2024-03-12 09:57:13 +00:00
|
|
|
"persistence",
|
|
|
|
"prover",
|
2024-03-29 17:15:21 +00:00
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
|
|
|
|
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm",
|
|
|
|
"--circom-zkey=tests/circuits/fixtures/proof_main.zkey",
|
2024-11-25 11:23:04 +00:00
|
|
|
"--eth-provider=http://127.0.0.1:8545",
|
2023-05-15 07:02:57 +00:00
|
|
|
"--eth-account=" & $account1
|
|
|
|
]
|
|
|
|
|
|
|
|
if debug1 != "true" and debug1 != "false":
|
|
|
|
node1Args.add("--log-level=" & debug1)
|
|
|
|
|
|
|
|
node1 = startNode(node1Args, debug = debug1)
|
2023-09-13 14:17:56 +00:00
|
|
|
node1.waitUntilStarted()
|
2023-03-27 13:47:25 +00:00
|
|
|
|
2024-03-19 03:25:13 +00:00
|
|
|
let bootstrap = (!client1.info()["spr"]).getStr()
|
2023-03-27 13:47:25 +00:00
|
|
|
|
2023-05-15 07:02:57 +00:00
|
|
|
var node2Args = @[
|
2023-03-27 13:47:25 +00:00
|
|
|
"--api-port=8081",
|
|
|
|
"--data-dir=" & dataDir2,
|
|
|
|
"--nat=127.0.0.1",
|
|
|
|
"--disc-ip=127.0.0.1",
|
|
|
|
"--disc-port=8091",
|
2023-10-24 14:52:06 +00:00
|
|
|
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
2023-03-27 13:47:25 +00:00
|
|
|
"--bootstrap-node=" & bootstrap,
|
2024-03-12 09:57:13 +00:00
|
|
|
"persistence",
|
|
|
|
"prover",
|
2024-03-29 17:15:21 +00:00
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
|
|
|
|
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm",
|
|
|
|
"--circom-zkey=tests/circuits/fixtures/proof_main.zkey",
|
2024-11-25 11:23:04 +00:00
|
|
|
"--eth-provider=http://127.0.0.1:8545",
|
2023-05-15 07:02:57 +00:00
|
|
|
"--eth-account=" & $account2
|
|
|
|
]
|
|
|
|
|
|
|
|
if debug2 != "true" and debug2 != "false":
|
|
|
|
node2Args.add("--log-level=" & debug2)
|
|
|
|
|
|
|
|
node2 = startNode(node2Args, debug = debug2)
|
2023-09-13 14:17:56 +00:00
|
|
|
node2.waitUntilStarted()
|
2023-03-27 13:47:25 +00:00
|
|
|
|
2024-05-23 15:29:30 +00:00
|
|
|
# ensure that we have a recent block with a fresh timestamp
|
|
|
|
discard await send(ethProvider, "evm_mine")
|
|
|
|
|
2023-03-27 13:47:25 +00:00
|
|
|
teardown:
|
|
|
|
client1.close()
|
|
|
|
client2.close()
|
|
|
|
|
|
|
|
node1.stop()
|
|
|
|
node2.stop()
|
|
|
|
|
|
|
|
removeDir(dataDir1)
|
|
|
|
removeDir(dataDir2)
|
|
|
|
|
|
|
|
body
|