Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures in forge test not being caught #130

Open
austinabell opened this issue Jul 30, 2024 · 4 comments
Open

Failures in forge test not being caught #130

austinabell opened this issue Jul 30, 2024 · 4 comments

Comments

@austinabell
Copy link

austinabell commented Jul 30, 2024

I might be missing something here, but adding a panic in the guest does not make any of the tests fail:

diff --git a/methods/guest/src/bin/is_even.rs b/methods/guest/src/bin/is_even.rs
index 9d834b6..0dba652 100644
--- a/methods/guest/src/bin/is_even.rs
+++ b/methods/guest/src/bin/is_even.rs
@@ -19,17 +19,18 @@ use alloy_sol_types::SolValue;
 use risc0_zkvm::guest::env;
 
 fn main() {
diff --git a/methods/guest/src/bin/is_even.rs b/methods/guest/src/bin/is_even.rs
index 9d834b6..19b1163 100644
--- a/methods/guest/src/bin/is_even.rs
+++ b/methods/guest/src/bin/is_even.rs
@@ -19,17 +19,5 @@ use alloy_sol_types::SolValue;
 use risc0_zkvm::guest::env;
 
 fn main() {
-    // Read the input data for this application.
-    let mut input_bytes = Vec::<u8>::new();
-    env::stdin().read_to_end(&mut input_bytes).unwrap();
-    // Decode and parse the input
-    let number = <U256>::abi_decode(&input_bytes, true).unwrap();
-
-    // Run the computation.
-    // In this case, asserting that the provided number is even.
-    assert!(!number.bit(0), "number is not even");
-
-    // Commit the journal that will be received by the application contract.
-    // Journal is encoded using Solidity ABI for easy decoding in the app contract.
-    env::commit_slice(number.abi_encode().as_slice());
+    panic!("test");
 }

output:

~/dev/ris/risc0-foundry-template (main|✚1) 🌲 forge test -vvv
[⠊] Compiling...
No files changed, compilation skipped

Ran 2 tests for tests/EvenNumber.t.sol:EvenNumberTest
[PASS] test_SetEven() (gas: 294609)
Logs:
  Deployed RiscZeroGroth16Verifier to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f

[PASS] test_SetZero() (gas: 274756)
Logs:
  Deployed RiscZeroGroth16Verifier to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f

Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 92.60s (148.42s CPU time)

Ran 1 test suite in 92.61s (92.60s CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)

Copy link

linear bot commented Jul 30, 2024

@nategraf nategraf added the bug Something isn't working label Aug 1, 2024
@nategraf
Copy link
Contributor

nategraf commented Aug 1, 2024

So, I'm guessing this is because you are not running cargo build after making that change. We don't have any mechanism in place to build the guest when someone runs forge build and forge test right now. This is a good issue to raise though, because I am sure other folks will trip over this.

@nategraf nategraf added discussion and removed bug Something isn't working labels Aug 1, 2024
@austinabell
Copy link
Author

ah, you're right, that was dumb. I swear I had rebuilt before running test.

Feel free to close, but sounds like you may want to keep this open?

@nategraf
Copy link
Contributor

nategraf commented Aug 2, 2024

I want to bring it up for discussion at the next web3 sync. Maybe there is a way we can ensure that the ELF elf is up to date when forge test runs.

@nategraf nategraf added the build label Oct 22, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants