2023-09-13 14:17:56 +00:00
|
|
|
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
|
2024-12-17 13:01:41 +00:00
|
|
|
import ../asynctest
|
|
|
|
import ../checktest
|
|
|
|
import ./codexprocess
|
|
|
|
import ./nodeprocess
|
2024-09-23 14:37:17 +00:00
|
|
|
import ../examples
|
2023-09-13 14:17:56 +00:00
|
|
|
|
2024-12-17 13:01:41 +00:00
|
|
|
asyncchecksuite "Command line interface":
|
2023-09-13 14:17:56 +00:00
|
|
|
|
|
|
|
let key = "4242424242424242424242424242424242424242424242424242424242424242"
|
|
|
|
|
2024-12-17 13:01:41 +00:00
|
|
|
proc startCodex(args: seq[string]): Future[CodexProcess] {.async.} =
|
|
|
|
return await CodexProcess.startNode(
|
|
|
|
args,
|
|
|
|
false,
|
|
|
|
"cli-test-node"
|
|
|
|
)
|
|
|
|
|
2023-09-13 14:17:56 +00:00
|
|
|
test "complains when persistence is enabled without ethereum account":
|
2024-12-17 13:01:41 +00:00
|
|
|
let node = await startCodex(@[
|
2024-03-12 09:57:13 +00:00
|
|
|
"persistence"
|
|
|
|
])
|
2024-12-17 13:01:41 +00:00
|
|
|
await node.waitUntilOutput("Persistence enabled, but no Ethereum account was set")
|
|
|
|
await node.stop()
|
2023-09-13 14:17:56 +00:00
|
|
|
|
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)
|
2024-12-17 13:01:41 +00:00
|
|
|
let node = await startCodex(@[
|
2024-03-12 09:57:13 +00:00
|
|
|
"persistence",
|
|
|
|
"--eth-private-key=" & unsafeKeyFile])
|
2024-12-17 13:01:41 +00:00
|
|
|
await node.waitUntilOutput("Ethereum private key file does not have safe file permissions")
|
|
|
|
await 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":
|
2024-12-17 13:01:41 +00:00
|
|
|
let node = await startCodex(@["persistence", "prover", marketplaceArg])
|
|
|
|
await node.waitUntilOutput(expectedDownloadInstruction)
|
|
|
|
await node.stop()
|
2023-09-13 14:17:56 +00:00
|
|
|
|
2024-09-23 14:37:17 +00:00
|
|
|
test "suggests downloading of circuit files when persistence is enabled without accessible wasm file":
|
2024-12-17 13:01:41 +00:00
|
|
|
let node = await startCodex(@[
|
2024-03-12 09:57:13 +00:00
|
|
|
"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-12-17 13:01:41 +00:00
|
|
|
await node.waitUntilOutput(expectedDownloadInstruction)
|
|
|
|
await node.stop()
|
2023-09-13 14:17:56 +00:00
|
|
|
|
2024-09-23 14:37:17 +00:00
|
|
|
test "suggests downloading of circuit files when persistence is enabled without accessible zkey file":
|
2024-12-17 13:01:41 +00:00
|
|
|
let node = await startCodex(@[
|
2024-03-12 09:57:13 +00:00
|
|
|
"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-12-17 13:01:41 +00:00
|
|
|
await node.waitUntilOutput(expectedDownloadInstruction)
|
|
|
|
await node.stop()
|