Skip to content

Commit

Permalink
fix: noir test incorrect reporting (#4925)
Browse files Browse the repository at this point in the history
fixes: #4912
  • Loading branch information
Maddiaa0 authored Mar 4, 2024
1 parent e775ead commit d98db3a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
8 changes: 4 additions & 4 deletions noir-projects/noir-protocol-circuits/crates/types/src/hash.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use crate::abis::side_effect::{SideEffect};
use crate::utils::uint256::U256;
use crate::constants::{
ARGS_HASH_CHUNK_COUNT, ARGS_HASH_CHUNK_LENGTH, CONTRACT_TREE_HEIGHT, FUNCTION_TREE_HEIGHT,
NUM_FIELDS_PER_SHA256, GENERATOR_INDEX__SILOED_NOTE_HASH,
GENERATOR_INDEX__OUTER_NULLIFIER, GENERATOR_INDEX__VK, GENERATOR_INDEX__CONSTRUCTOR,
GENERATOR_INDEX__PARTIAL_ADDRESS, GENERATOR_INDEX__CONTRACT_ADDRESS,
GENERATOR_INDEX__NOTE_HASH_NONCE, GENERATOR_INDEX__UNIQUE_NOTE_HASH, GENERATOR_INDEX__FUNCTION_ARGS
NUM_FIELDS_PER_SHA256, GENERATOR_INDEX__SILOED_NOTE_HASH, GENERATOR_INDEX__OUTER_NULLIFIER,
GENERATOR_INDEX__VK, GENERATOR_INDEX__CONSTRUCTOR, GENERATOR_INDEX__PARTIAL_ADDRESS,
GENERATOR_INDEX__CONTRACT_ADDRESS, GENERATOR_INDEX__NOTE_HASH_NONCE,
GENERATOR_INDEX__UNIQUE_NOTE_HASH, GENERATOR_INDEX__FUNCTION_ARGS
};
use crate::messaging::l2_to_l1_message::L2ToL1Message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ impl PreviousKernelDataBuilder {
}

fn get_mock_nullifier_value(self, nullifier_index: u64) -> Field {
let first_nullifier = self.end.new_nullifiers.get(0);
first_nullifier.value + nullifier_index as Field
let first_nullifier = if (self.end.new_nullifiers.len() > 0) {
self.end.new_nullifiers.get(0).value
} else {
0 as Field
};

first_nullifier + nullifier_index as Field
}

pub fn append_new_nullifiers_from_private(&mut self, num_extra_nullifier: u64) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// Test to make sure the entire test suite fails, even if some of the tests pass!
#[test]
fn this_will_pass() {
assert(true);
}

#[test]
fn this_will_fail() {
assert(false);
}
6 changes: 3 additions & 3 deletions noir/noir-repo/tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ pub(crate) fn run(
};
}

if test_report.iter().any(|(_, status)| !matches!(status, TestStatus::Fail { .. })) {
Ok(())
} else {
if test_report.iter().any(|(_, status)| matches!(status, TestStatus::Fail { .. })) {
Err(CliError::Generic(String::new()))
} else {
Ok(())
}
}

Expand Down

0 comments on commit d98db3a

Please sign in to comment.