improve integration tests

- rename `expectedErrCode` to `expectedExitCode`
- add comments to testcli integration test explaining why we expect a non-zero exit code for the codex process in the test
This commit is contained in:
E M 2026-01-16 15:08:06 +11:00
parent 4efd4c458d
commit ce127b383d
No known key found for this signature in database
2 changed files with 17 additions and 7 deletions

View File

@ -66,7 +66,9 @@ asyncchecksuite "Command line interface":
test "complains when persistence is enabled without ethereum account":
let node = await startCodex(@["persistence"])
await node.waitUntilOutput("Persistence enabled, but no Ethereum account was set")
await node.stop(expectedErrCode = 1)
# Expect the codex process to return an exit code of 1 indicating the result
# of the operation was unsuccessful.
await node.stop(expectedExitCode = 1)
test "complains when ethereum private key file has wrong permissions":
let unsafeKeyFile = genTempPath("", "")
@ -81,7 +83,9 @@ asyncchecksuite "Command line interface":
await node.waitUntilOutput(
"Ethereum private key file does not have safe file permissions"
)
await node.stop(expectedErrCode = 1)
# Expect the codex process to return an exit code of 1 indicating the result
# of the operation was unsuccessful.
await node.stop(expectedExitCode = 1)
discard removeFile(unsafeKeyFile)
let
@ -92,7 +96,9 @@ asyncchecksuite "Command line interface":
test "suggests downloading of circuit files when persistence is enabled without accessible r1cs file":
let node = await startCodex(@["persistence", "prover", marketplaceArg])
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop(expectedErrCode = 1)
# Expect the codex process to return an exit code of 1 indicating the result
# of the operation was unsuccessful.
await node.stop(expectedExitCode = 1)
test "suggests downloading of circuit files when persistence is enabled without accessible wasm file":
let node = await startCodex(
@ -105,7 +111,9 @@ asyncchecksuite "Command line interface":
]
)
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop(expectedErrCode = 1)
# Expect the codex process to return an exit code of 1 indicating the result
# of the operation was unsuccessful.
await node.stop(expectedExitCode = 1)
test "suggests downloading of circuit files when persistence is enabled without accessible zkey file":
let node = await startCodex(
@ -119,4 +127,6 @@ asyncchecksuite "Command line interface":
]
)
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop(expectedErrCode = 1)
# Expect the codex process to return an exit code of 1 indicating the result
# of the operation was unsuccessful.
await node.stop(expectedExitCode = 1)

View File

@ -117,7 +117,7 @@ proc startNode*[T: NodeProcess](
return node
method stop*(
node: NodeProcess, expectedErrCode: int = -1
node: NodeProcess, expectedExitCode: int = 0
) {.base, async: (raises: []).} =
logScope:
nodeName = node.name
@ -129,7 +129,7 @@ method stop*(
try:
let exitCode = await noCancel node.process.terminateAndWaitForExit(2.seconds)
if exitCode > 0 and exitCode != 143 and # 143 = SIGTERM (initiated above)
exitCode != expectedErrCode:
exitCode != expectedExitCode:
warn "process exited with a non-zero exit code", exitCode
trace "node process terminated", exitCode
except CatchableError: