diff --git a/tests/integration/nodeprocess.nim b/tests/integration/nodeprocess.nim index 3fbb4445..d5200a2f 100644 --- a/tests/integration/nodeprocess.nim +++ b/tests/integration/nodeprocess.nim @@ -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: diff --git a/tests/integration/testcli.nim b/tests/integration/testcli.nim index ef2a9df2..eaaf2810 100644 --- a/tests/integration/testcli.nim +++ b/tests/integration/testcli.nim @@ -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)