expect process exit code

prevents showing error in the logs when an expected process exit code is encountered

# Conflicts:
#	tests/integration/testcli.nim
This commit is contained in:
Eric 2025-01-14 14:58:08 +11:00
parent 05c002c973
commit 85db97d707
No known key found for this signature in database
2 changed files with 33 additions and 21 deletions

View File

@ -116,7 +116,7 @@ proc startNode*[T: NodeProcess](
await node.start()
return node
method stop*(node: NodeProcess) {.base, async.} =
method stop*(node: NodeProcess, expectedErrCode: int = -1) {.base, async.} =
logScope:
nodeName = node.name
@ -137,7 +137,9 @@ method stop*(node: NodeProcess) {.base, async.} =
fatal "could not get exit code from process", error
return
if exitCode > 0 and exitCode != 143: # 143 = SIGTERM (initiated above)
if exitCode > 0 and
exitCode != 143 and # 143 = SIGTERM (initiated above)
exitCode != expectedErrCode:
error "failed to exit process, check for zombies", exitCode
except CancelledError as error:

View File

@ -8,6 +8,8 @@ import ./nodeprocess
import ./utils
import ../examples
const HardhatPort {.intdefine.}: int = 8545
asyncchecksuite "Command line interface":
let key = "4242424242424242424242424242424242424242424242424242424242424242"
@ -29,16 +31,22 @@ 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()
await node.stop(expectedErrCode = 1)
test "complains when ethereum private key file has wrong permissions":
let unsafeKeyFile = genTempPath("", "")
discard unsafeKeyFile.writeFile(key, 0o666)
let node = await startCodex(@["persistence", "--eth-private-key=" & unsafeKeyFile])
let node = await startCodex(
@[
"persistence",
"--eth-provider=" & "http://127.0.0.1:" & $HardhatPort,
"--eth-private-key=" & unsafeKeyFile
]
)
await node.waitUntilOutput(
"Ethereum private key file does not have safe file permissions"
)
await node.stop()
await node.stop(expectedErrCode = 1)
discard removeFile(unsafeKeyFile)
let
@ -49,25 +57,27 @@ 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()
await node.stop(expectedErrCode = 1)
test "suggests downloading of circuit files when persistence is enabled without accessible wasm file":
let node = await startCodex(
@[
"persistence", "prover", marketplaceArg,
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs"
]
)
let node = await startCodex(@[
"persistence",ß
"--eth-provider=" & "http://127.0.0.1:" & $HardhatPort,
"prover",
marketplaceArg,
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs"
])
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop()
await node.stop(expectedErrCode = 1)
test "suggests downloading of circuit files when persistence is enabled without accessible zkey file":
let node = await startCodex(
@[
"persistence", "prover", marketplaceArg,
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm"
]
)
let node = await startCodex(@[
"persistence",
"--eth-provider=" & "http://127.0.0.1:" & $HardhatPort,
"prover",
marketplaceArg,
"--circom-r1cs=tests/circuits/fixtures/proof_main.r1cs",
"--circom-wasm=tests/circuits/fixtures/proof_main.wasm"
])
await node.waitUntilOutput(expectedDownloadInstruction)
await node.stop()
await node.stop(expectedErrCode = 1)