Skip to content

Commit

Permalink
1329 - fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 28, 2023
1 parent 9d1a18b commit a1b9243
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ TEST_F(native_private_kernel_tests, native_transient_read_requests_no_match)
// Testing that the special value EMPTY_NULLIFIED_COMMITMENT keeps new_nullifiers aligned with nullified_commitments.
TEST_F(native_private_kernel_tests, native_empty_nullified_commitment_respected)
{
// The 0th nullifier (and corresponding nullified_commitment EMPTY_NULLIFIED_COMMITMENT) which is
// added by the init iteration is set into private_inputs_inner.
auto private_inputs_inner = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args());

private_inputs_inner.private_call.call_stack_item.public_inputs.new_commitments[0] = fr(23);
Expand All @@ -189,30 +191,31 @@ TEST_F(native_private_kernel_tests, native_empty_nullified_commitment_respected)
<< " with code: " << builder.get_first_failure().code;

// EMPTY nullified commitment should keep new_nullifiers aligned with nullified_commitments
ASSERT_TRUE(public_inputs.end.nullified_commitments[0] == fr(EMPTY_NULLIFIED_COMMITMENT));
ASSERT_TRUE(public_inputs.end.nullified_commitments[1] != fr(0) &&
public_inputs.end.nullified_commitments[1] != fr(EMPTY_NULLIFIED_COMMITMENT));
// We have to shift the offset by 1 due to the 0th nullifier/nullified_commitment pair.
ASSERT_TRUE(public_inputs.end.nullified_commitments[1] == fr(EMPTY_NULLIFIED_COMMITMENT));
ASSERT_TRUE(public_inputs.end.nullified_commitments[2] != fr(0) &&
public_inputs.end.nullified_commitments[2] != fr(EMPTY_NULLIFIED_COMMITMENT));

// Nothing squashed yet (until ordering circuit)
ASSERT_TRUE(array_length(public_inputs.end.new_nullifiers) == 2);
ASSERT_TRUE(array_length(public_inputs.end.new_nullifiers) == 3); // 0th nullifier to be taking into account
ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 2);
// explicitly EMPTY commitment respected in array
ASSERT_TRUE(array_length(public_inputs.end.nullified_commitments) == 2);
ASSERT_TRUE(array_length(public_inputs.end.nullified_commitments) == 3);

auto& previous_kernel = private_inputs_inner.previous_kernel;
previous_kernel.public_inputs = public_inputs;

PrivateKernelInputsOrdering<NT> private_inputs{ .previous_kernel = previous_kernel,
.nullifier_commitment_hints =
std::array<fr, MAX_NEW_NULLIFIERS_PER_TX>{ 0, 1 } };
std::array<fr, MAX_NEW_NULLIFIERS_PER_TX>{ 0, 0, 1 } };

auto final_public_inputs = native_private_kernel_circuit_ordering(builder, private_inputs);

ASSERT_FALSE(builder.failed()) << "failure: " << builder.get_first_failure()
<< " with code: " << builder.get_first_failure().code;

ASSERT_TRUE(array_length(final_public_inputs.end.new_commitments) == 1); // 1/2 commitment squashed
ASSERT_TRUE(array_length(final_public_inputs.end.new_nullifiers) == 1); // 1/2 nullifier squashed
ASSERT_TRUE(array_length(final_public_inputs.end.new_nullifiers) == 2); // 1/2 nullifier squashed (+ 0th nullifier)
}

} // namespace aztec3::circuits::kernel::private_kernel
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ PrivateKernelInputsInner<NT> do_private_call_get_kernel_inputs_inner(
public_inputs_encrypted_log_preimages_length;
mock_previous_kernel.public_inputs.end.unencrypted_log_preimages_length =
public_inputs_unencrypted_log_preimages_length;
mock_previous_kernel.public_inputs.end.new_nullifiers[0] = 321; // 0th nullifier must be non-zero.
mock_previous_kernel.public_inputs.end.nullified_commitments[0] = EMPTY_NULLIFIED_COMMITMENT;

//***************************************************************************
// Now we can construct the full private inputs to the kernel circuit
Expand Down

0 comments on commit a1b9243

Please sign in to comment.