2023-09-13 14:17:56 +00:00
|
|
|
import std/unittest
|
|
|
|
import std/tempfiles
|
2024-03-12 09:57:13 +00:00
|
|
|
import codex/conf
|
2023-09-13 14:17:56 +00:00
|
|
|
import codex/utils/fileutils
|
|
|
|
import ./nodes
|
|
|
|
|
|
|
|
suite "Command line interface":
|
|
|
|
|
|
|
|
let key = "4242424242424242424242424242424242424242424242424242424242424242"
|
|
|
|
|
|
|
|
test "complains when persistence is enabled without ethereum account":
|
2024-03-12 09:57:13 +00:00
|
|
|
let node = startNode(@[
|
|
|
|
"persistence"
|
|
|
|
])
|
2023-09-13 14:17:56 +00:00
|
|
|
node.waitUntilOutput("Persistence enabled, but no Ethereum account was set")
|
|
|
|
node.stop()
|
|
|
|
|
2024-03-12 09:57:13 +00:00
|
|
|
test "complains when ethereum private key file has wrong permissions":
|
|
|
|
let unsafeKeyFile = genTempPath("", "")
|
|
|
|
discard unsafeKeyFile.writeFile(key, 0o666)
|
|
|
|
let node = startNode(@[
|
|
|
|
"persistence",
|
|
|
|
"--eth-private-key=" & unsafeKeyFile])
|
|
|
|
node.waitUntilOutput("Ethereum private key file does not have safe file permissions")
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|
2024-03-12 09:57:13 +00:00
|
|
|
discard removeFile(unsafeKeyFile)
|
2023-09-13 14:17:56 +00:00
|
|
|
|
2024-03-12 09:57:13 +00:00
|
|
|
test "complains when persistence is enabled without accessible r1cs file":
|
|
|
|
let node = startNode(@["persistence", "prover"])
|
|
|
|
node.waitUntilOutput("r1cs file not readable, doesn't exist or wrong extension (.r1cs)")
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|
|
|
|
|
2024-03-12 09:57:13 +00:00
|
|
|
test "complains when persistence is enabled without accessible wasm file":
|
|
|
|
let node = startNode(@[
|
|
|
|
"persistence",
|
|
|
|
"prover",
|
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs"
|
|
|
|
])
|
|
|
|
node.waitUntilOutput("wasm file not readable, doesn't exist or wrong extension (.wasm)")
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|
|
|
|
|
2024-03-12 09:57:13 +00:00
|
|
|
test "complains when persistence is enabled without accessible zkey file":
|
|
|
|
let node = startNode(@[
|
|
|
|
"persistence",
|
|
|
|
"prover",
|
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
|
|
|
|
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm"
|
|
|
|
])
|
|
|
|
node.waitUntilOutput("zkey file not readable, doesn't exist or wrong extension (.zkey)")
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|