refactor: simplify error handling in suggestDownloadTool and enhance test setup for CLI

This commit is contained in:
Dmitriy Ryajov 2025-05-30 18:25:06 -06:00 committed by Eric
parent ebf4ce4c6f
commit 71fdf952cf
No known key found for this signature in database
2 changed files with 15 additions and 8 deletions

View File

@ -71,9 +71,7 @@ proc getZkeyFile*(config: CodexConf): ?!string =
proc suggestDownloadTool(config: CodexConf) =
without address =? config.marketplaceAddress:
raise (ref Defect)(
msg: "Proving backend initializing while marketplace address not set."
)
raiseAssert("Proving backend initializing while marketplace address not set.")
let
tokens = ["cirdl", "\"" & $config.circuitDir & "\"", config.ethProvider, $address]

View File

@ -65,6 +65,10 @@ asyncchecksuite "Command line interface":
test "complains when persistence is enabled without ethereum account":
let node = await startCodex(@["persistence"])
defer:
await node.stop()
await node.waitUntilOutput("Persistence enabled, but no Ethereum account was set")
await node.stop(expectedErrCode = 1)
@ -84,10 +88,8 @@ asyncchecksuite "Command line interface":
await node.stop(expectedErrCode = 1)
discard removeFile(unsafeKeyFile)
let
marketplaceArg = "--marketplace-address=" & $EthAddress.example
expectedDownloadInstruction =
"Proving circuit files are not found. Please run the following to download them:"
let 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 = await startCodex(@["persistence", "prover", marketplaceArg])
@ -104,6 +106,10 @@ asyncchecksuite "Command line interface":
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
]
)
defer:
await node.stop()
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop(expectedErrCode = 1)
@ -115,8 +121,11 @@ asyncchecksuite "Command line interface":
"prover",
marketplaceArg,
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm",
]
)
defer:
await node.stop()
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop(expectedErrCode = 1)