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

1242 - e2e test related to the filtering of get_notes #1570

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ using aztec3::utils::array_length;
using aztec3::utils::CircuitErrorCode;


// TODO(https://github.com/AztecProtocol/aztec-packages/issues/892): test expected kernel failures if transient reads
// (or their hints) don't match
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/836): test expected kernel failures if nullifiers (or
// their hints) don't match

/**************************************************************
* MULTI ITERATION UNIT TESTS FOR NATIVE PRIVATE KERNEL CIRCUIT
**************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe('e2e_pending_commitments_contract', () => {
owner,
Fr.fromBuffer(deployedContract.methods.insert_note.selector),
Fr.fromBuffer(deployedContract.methods.get_then_nullify_note.selector),
//Fr.fromBuffer(deployedContract.methods.get_note_zero_balance.selector),
)
.send({ origin: owner });

Expand Down Expand Up @@ -199,10 +198,39 @@ describe('e2e_pending_commitments_contract', () => {
await expectNullifiersSquashedExcept(1);
}, 60_000);

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/836): test nullify & squash of pending notes
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/892): test expected kernel failures if transient reads (or their hints) don't match
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/836): test expected kernel failures if nullifiers (or their hints) don't match
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/839): test creation, getting, nullifying of multiple notes
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1242): test nullifying a note created in a previous transaction and
// get_notes in the same transaction should not return it.
it('get_notes function filters a nullified note created in a previous transaction', async () => {
// Create a note in an isolated transaction.
// In a subsequent transaction, we nullify the note and a call to 'get note' should
// not return anything.
// Remark: This test can be seen as a simplification of the previous one but has the merit to
// isolate the simplest 'get note' filtering with a pending nullifier on a persistent note.
const mintAmount = 65n;

const deployedContract = await deployContract();
const tx0 = deployedContract.methods.insert_note(mintAmount, owner).send({ origin: owner });

await tx0.isMined({ interval: 0.1 });
const receipt = await tx0.getReceipt();
expect(receipt.status).toBe(TxStatus.MINED);

// There is a single new commitment/note.
await expectCommitmentsSquashedExcept(1);

const tx1 = deployedContract.methods
.test_insert_then_get_then_nullify_all_in_nested_calls(
mintAmount,
owner,
Fr.fromBuffer(deployedContract.methods.dummy.selector),
Fr.fromBuffer(deployedContract.methods.get_then_nullify_note.selector),
Fr.fromBuffer(deployedContract.methods.get_note_zero_balance.selector),
)
.send({ origin: owner });

await tx1.isMined({ interval: 0.1 });
const receipt2 = await tx1.getReceipt();
expect(receipt2.status).toBe(TxStatus.MINED);

// There is a single new nullifier.
await expectNullifiersSquashedExcept(1);
}, 60_000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ contract PendingCommitments {
context.finish()
}

// Dumy nested/inner function (to pass a function which does nothing)
fn dummy(
//*********************************/
// Should eventually be hidden:
inputs: PrivateContextInputs,
//*********************************/
amount: Field,
owner: Field,
) -> distinct pub abi::PrivateCircuitPublicInputs {
let storage = Storage::init();
let mut context = Context::new(inputs, abi::hash_args([amount, owner]));
context.finish()
}

// Nested/inner function to create and insert a note
fn insert_note(
//*********************************/
Expand Down