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
|
2024-09-23 14:37:17 +00:00
|
|
|
import ../examples
|
2023-09-13 14:17:56 +00:00
|
|
|
|
|
|
|
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-09-23 14:37:17 +00:00
|
|
|
let
|
|
|
|
marketplaceArg = "--marketplace-address=" & $EthAddress.example
|
|
|
|
expectedDownloadInstruction = "Proving circuit files are not found. Please run the following to download them:"
|
|
|
|
|
|
|
|
test "suggests downloading of circuit files when persistence is enabled without accessible r1cs file":
|
|
|
|
let node = startNode(@["persistence", "prover", marketplaceArg])
|
|
|
|
node.waitUntilOutput(expectedDownloadInstruction)
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|
|
|
|
|
2024-09-23 14:37:17 +00:00
|
|
|
test "suggests downloading of circuit files when persistence is enabled without accessible wasm file":
|
2024-03-12 09:57:13 +00:00
|
|
|
let node = startNode(@[
|
|
|
|
"persistence",
|
|
|
|
"prover",
|
2024-09-23 14:37:17 +00:00
|
|
|
marketplaceArg,
|
2024-03-12 09:57:13 +00:00
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs"
|
|
|
|
])
|
2024-09-23 14:37:17 +00:00
|
|
|
node.waitUntilOutput(expectedDownloadInstruction)
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|
|
|
|
|
2024-09-23 14:37:17 +00:00
|
|
|
test "suggests downloading of circuit files when persistence is enabled without accessible zkey file":
|
2024-03-12 09:57:13 +00:00
|
|
|
let node = startNode(@[
|
|
|
|
"persistence",
|
|
|
|
"prover",
|
2024-09-23 14:37:17 +00:00
|
|
|
marketplaceArg,
|
2024-03-12 09:57:13 +00:00
|
|
|
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
|
|
|
|
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm"
|
|
|
|
])
|
2024-09-23 14:37:17 +00:00
|
|
|
node.waitUntilOutput(expectedDownloadInstruction)
|
2023-09-13 14:17:56 +00:00
|
|
|
node.stop()
|