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() await node.start()
return node return node
method stop*(node: NodeProcess) {.base, async.} = method stop*(node: NodeProcess, expectedErrCode: int = -1) {.base, async.} =
logScope: logScope:
nodeName = node.name nodeName = node.name
@ -137,7 +137,9 @@ method stop*(node: NodeProcess) {.base, async.} =
fatal "could not get exit code from process", error fatal "could not get exit code from process", error
return 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 error "failed to exit process, check for zombies", exitCode
except CancelledError as error: except CancelledError as error:

View File

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