From 1f033aa0c0f5f21ea3d58274da1e761e17b131e9 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Tue, 19 Mar 2024 20:29:13 +0000 Subject: [PATCH 01/15] Fix --- noir-projects/aztec-nr/aztec/src/note/note_getter.nr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter.nr index 679f097ee65..a2f1b30f6bc 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter.nr @@ -126,6 +126,9 @@ pub fn get_notes( if options.limit != 0 { assert(num_notes <= options.limit, "Invalid number of return notes."); } + + assert(num_notes != 0, "Cannot return zero notes"); + opt_notes } From d959504d694458063e60032c2158c60611dd0c27 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 00:39:05 +0000 Subject: [PATCH 02/15] add failing test --- .../simulator/src/client/private_execution.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 2abe169627f..237035b6235 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -50,12 +50,13 @@ import { jest } from '@jest/globals'; import { MockProxy, mock } from 'jest-mock-extended'; import { toFunctionSelector } from 'viem'; -import { KeyPair, MessageLoadOracleInputs } from '../acvm/index.js'; +import { KeyPair, MessageLoadOracleInputs, NoteData, Oracle } from '../acvm/index.js'; import { buildL1ToL2Message } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; import { DBOracle } from './db_oracle.js'; import { collectUnencryptedLogs } from './execution_result.js'; import { AcirSimulator } from './simulator.js'; +import { ClientExecutionContext } from './client_execution_context.js'; jest.setTimeout(60_000); @@ -1069,6 +1070,17 @@ describe('Private Execution test suite', () => { }); }); + describe('Get notes', () => { + it('fails if returning no notes', async () => { + const artifact = getFunctionArtifact(TestContractArtifact, 'call_get_notes'); + + const args = [2n, true]; + oracle.getNotes.mockResolvedValue([]); + + await expect(runSimulator({ artifact, args })).rejects.toThrow(); + }); + }); + describe('Context oracles', () => { it("Should be able to get and return the contract's portal contract address", async () => { const portalContractAddress = EthAddress.random(); From 3402cb34bf32bce3ff1c46d24b73fdcf72a10500 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 00:39:40 +0000 Subject: [PATCH 03/15] fix --- yarn-project/simulator/src/client/private_execution.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 237035b6235..c5df267eab4 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -50,13 +50,12 @@ import { jest } from '@jest/globals'; import { MockProxy, mock } from 'jest-mock-extended'; import { toFunctionSelector } from 'viem'; -import { KeyPair, MessageLoadOracleInputs, NoteData, Oracle } from '../acvm/index.js'; +import { KeyPair, MessageLoadOracleInputs } from '../acvm/index.js'; import { buildL1ToL2Message } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; import { DBOracle } from './db_oracle.js'; import { collectUnencryptedLogs } from './execution_result.js'; import { AcirSimulator } from './simulator.js'; -import { ClientExecutionContext } from './client_execution_context.js'; jest.setTimeout(60_000); From 0c50892c4000813bc650f41ee5696a94001ee732 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 16:42:21 +0000 Subject: [PATCH 04/15] Fixing broken tests --- .../end-to-end/src/e2e_blacklist_token_contract.test.ts | 2 +- yarn-project/end-to-end/src/e2e_card_game.test.ts | 2 +- yarn-project/end-to-end/src/e2e_note_getter.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts index 8d6e232fbb1..310a183fc30 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts @@ -389,7 +389,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( - 'Can only remove a note that has been read from the set.', + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); }); diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/e2e_card_game.test.ts index 6e26b459fad..6fa22829dd2 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/e2e_card_game.test.ts @@ -172,7 +172,7 @@ describe('e2e_card_game', () => { .join_game(GAME_ID, [cardToField(firstPlayerCollection[0]), cardToField(firstPlayerCollection[1])]) .send() .wait(), - ).rejects.toThrow(/Card not found/); + ).rejects.toThrow(`Assertion failed: Cannot return zero notes 'num_notes != 0'`); const collection = await contract.methods.view_collection_cards(firstPlayer, 0).view({ from: firstPlayer }); expect(unwrapOptions(collection)).toHaveLength(1); diff --git a/yarn-project/end-to-end/src/e2e_note_getter.test.ts b/yarn-project/end-to-end/src/e2e_note_getter.test.ts index 6641b391149..acf60b61818 100644 --- a/yarn-project/end-to-end/src/e2e_note_getter.test.ts +++ b/yarn-project/end-to-end/src/e2e_note_getter.test.ts @@ -176,7 +176,7 @@ describe('e2e_note_getter', () => { async function assertNoReturnValue(storageSlot: number, activeOrNullified: boolean) { await expect(contract.methods.call_view_notes(storageSlot, activeOrNullified).view()).rejects.toThrow('is_some'); await expect(contract.methods.call_get_notes(storageSlot, activeOrNullified).send().wait()).rejects.toThrow( - 'is_some', + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); } From 7ad5ad403c5f7b88d7f92b4d0de1c6e17329ea87 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 17:41:42 +0000 Subject: [PATCH 05/15] token --- yarn-project/end-to-end/src/e2e_token_contract.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index 04420c05075..fb3c35c1f6d 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -275,7 +275,7 @@ describe('e2e_token_contract', () => { 'The note has been destroyed.', ); await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( - 'Can only remove a note that has been read from the set.', + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); }); From b1bf1dd465cd5430cc6301c445a376e0c9454135 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 19:02:37 +0000 Subject: [PATCH 06/15] fix pending note hash contract --- .../contracts/pending_note_hashes_contract/src/main.nr | 9 +-------- .../src/e2e_pending_note_hashes_contract.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index a46df1a92db..49d958fd97e 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -110,8 +110,7 @@ contract PendingNoteHashes { amount: Field, owner: AztecAddress, insert_fn_selector: FunctionSelector, - get_then_nullify_fn_selector: FunctionSelector, - get_note_zero_fn_selector: FunctionSelector + get_then_nullify_fn_selector: FunctionSelector ) { // nested call to create/insert note let _callStackItem1 = context.call_private_function( @@ -125,12 +124,6 @@ contract PendingNoteHashes { get_then_nullify_fn_selector, [amount, owner.to_field()] ); - // nested call to confirm that balance is zero - let _callStackItem3 = context.call_private_function( - inputs.call_context.storage_contract_address, - get_note_zero_fn_selector, - [owner.to_field()] - ); } // same test as above, but insert 2, get 2, nullify 2 diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index 37e1cbdefdb..312c4e68aa9 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -79,10 +79,10 @@ describe('e2e_pending_note_hashes_contract', () => { owner, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, - deployedContract.methods.get_note_zero_balance.selector, ) .send() .wait(); + await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); await expectNoteHashesSquashedExcept(0); await expectNullifiersSquashedExcept(0); @@ -186,10 +186,10 @@ describe('e2e_pending_note_hashes_contract', () => { owner, deployedContract.methods.dummy.selector, deployedContract.methods.get_then_nullify_note.selector, - deployedContract.methods.get_note_zero_balance.selector, ) .send() .wait(); + await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); // There is a single new nullifier. await expectNullifiersSquashedExcept(1); From adb29eae6cc53eb48b82db0e392cdea4a121c35d Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 19:39:25 +0000 Subject: [PATCH 07/15] fix --- .../src/client/private_execution.test.ts | 53 +------------------ 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index c5df267eab4..6e52b5a4f18 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -918,17 +918,11 @@ describe('Private Execution test suite', () => { const getThenNullifyArtifact = getFunctionArtifact(PendingNoteHashesContractArtifact, 'get_then_nullify_note'); - const getZeroArtifact = getFunctionArtifact(PendingNoteHashesContractArtifact, 'get_note_zero_balance'); - const insertFnSelector = FunctionSelector.fromNameAndParameters(insertArtifact.name, insertArtifact.parameters); const getThenNullifyFnSelector = FunctionSelector.fromNameAndParameters( getThenNullifyArtifact.name, getThenNullifyArtifact.parameters, ); - const getZeroFnSelector = FunctionSelector.fromNameAndParameters( - getZeroArtifact.name, - getZeroArtifact.parameters, - ); oracle.getPortalContractAddress.mockImplementation(() => Promise.resolve(EthAddress.ZERO)); @@ -937,7 +931,6 @@ describe('Private Execution test suite', () => { owner, insertFnSelector.toField(), getThenNullifyFnSelector.toField(), - getZeroFnSelector.toField(), ]; const result = await runSimulator({ args: args, @@ -947,7 +940,6 @@ describe('Private Execution test suite', () => { const execInsert = result.nestedExecutions[0]; const execGetThenNullify = result.nestedExecutions[1]; - const getNotesAfterNullify = result.nestedExecutions[2]; const storageSlot = computeSlotForMapping(new Fr(1n), owner); const noteTypeId = new Fr(869710811710178111116101n); // ValueNote @@ -991,10 +983,6 @@ describe('Private Execution test suite', () => { siloedNullifierSecretKey.high, ]); expect(nullifier.value).toEqual(expectedNullifier); - - // check that the last get_notes call return no note - const afterNullifyingNoteValue = getNotesAfterNullify.callStackItem.publicInputs.returnValues[0].value; - expect(afterNullifyingNoteValue).toEqual(0n); }); it('cant read a commitment that is inserted later in same call', async () => { @@ -1007,48 +995,11 @@ describe('Private Execution test suite', () => { const artifact = getFunctionArtifact(PendingNoteHashesContractArtifact, 'test_bad_get_then_insert_flat'); const args = [amountToTransfer, owner]; - const result = await runSimulator({ + await expect(runSimulator({ args: args, artifact: artifact, contractAddress, - }); - - const storageSlot = computeSlotForMapping(new Fr(1n), owner); - const noteTypeId = new Fr(869710811710178111116101n); // ValueNote - - expect(result.newNotes).toHaveLength(1); - const noteAndSlot = result.newNotes[0]; - expect(noteAndSlot.storageSlot).toEqual(storageSlot); - expect(noteAndSlot.noteTypeId).toEqual(noteTypeId); - - expect(noteAndSlot.note.items[0]).toEqual(new Fr(amountToTransfer)); - - const newNoteHashes = sideEffectArrayToValueArray( - nonEmptySideEffects(result.callStackItem.publicInputs.newNoteHashes), - ); - expect(newNoteHashes).toHaveLength(1); - - const noteHash = newNoteHashes[0]; - expect(noteHash).toEqual( - await acirSimulator.computeInnerNoteHash( - contractAddress, - storageSlot, - noteAndSlot.noteTypeId, - noteAndSlot.note, - ), - ); - - // read requests should be empty - const readRequest = result.callStackItem.publicInputs.noteHashReadRequests[0].value; - expect(readRequest).toEqual(Fr.ZERO); - - // should get note value 0 because it actually gets a fake note since the real one hasn't been inserted yet! - const gotNoteValue = result.callStackItem.publicInputs.returnValues[0]; - expect(gotNoteValue).toEqual(Fr.ZERO); - - // there should be no nullifiers - const nullifier = result.callStackItem.publicInputs.newNullifiers[0].value; - expect(nullifier).toEqual(Fr.ZERO); + })).rejects.toThrow(); }); }); From 16a7de155112a041cced7bcbdfff2254e8cb20c3 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 19:42:40 +0000 Subject: [PATCH 08/15] fix --- .../contracts/pending_note_hashes_contract/src/main.nr | 6 ------ .../end-to-end/src/e2e_pending_note_hashes_contract.test.ts | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index 49d958fd97e..da29a42f6dc 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -225,12 +225,6 @@ contract PendingNoteHashes { get_then_nullify_fn_selector, args ); - - let _callStackItem4 = context.call_private_function( - inputs.call_context.storage_contract_address, - get_note_zero_fn_selector, - [owner.to_field()] - ); } // Confirm cannot get/read a pending note hash in a nested call // that is created/inserted later in execution but in the parent. diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index 312c4e68aa9..4f8cc56b7ac 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -154,10 +154,10 @@ describe('e2e_pending_note_hashes_contract', () => { owner, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, - deployedContract.methods.get_note_zero_balance.selector, ) .send() .wait(); + await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); // second TX creates 1 note, but it is squashed! await expectNoteHashesSquashedExcept(0); @@ -189,7 +189,6 @@ describe('e2e_pending_note_hashes_contract', () => { ) .send() .wait(); - await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); // There is a single new nullifier. await expectNullifiersSquashedExcept(1); From f75b7db0044cdcf9a4bba7e10c21321bac3cf300 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 20:01:08 +0000 Subject: [PATCH 09/15] fix --- .../contracts/pending_note_hashes_contract/src/main.nr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index da29a42f6dc..7d3fcd593b8 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -202,8 +202,7 @@ contract PendingNoteHashes { amount: Field, owner: AztecAddress, insert_fn_selector: FunctionSelector, - get_then_nullify_fn_selector: FunctionSelector, - get_note_zero_fn_selector: FunctionSelector + get_then_nullify_fn_selector: FunctionSelector ) { // args for nested calls let args = [amount, owner.to_field()]; From 109aee5ddfaeeadb79c990c7d23e2010c4fe22df Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 20 Mar 2024 21:57:01 +0000 Subject: [PATCH 10/15] fix --- .../src/client/private_execution.test.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 6e52b5a4f18..6a2117e0fff 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -926,12 +926,7 @@ describe('Private Execution test suite', () => { oracle.getPortalContractAddress.mockImplementation(() => Promise.resolve(EthAddress.ZERO)); - const args = [ - amountToTransfer, - owner, - insertFnSelector.toField(), - getThenNullifyFnSelector.toField(), - ]; + const args = [amountToTransfer, owner, insertFnSelector.toField(), getThenNullifyFnSelector.toField()]; const result = await runSimulator({ args: args, artifact: artifact, @@ -995,11 +990,13 @@ describe('Private Execution test suite', () => { const artifact = getFunctionArtifact(PendingNoteHashesContractArtifact, 'test_bad_get_then_insert_flat'); const args = [amountToTransfer, owner]; - await expect(runSimulator({ - args: args, - artifact: artifact, - contractAddress, - })).rejects.toThrow(); + await expect( + runSimulator({ + args: args, + artifact: artifact, + contractAddress, + }), + ).rejects.toThrow(); }); }); From 2353c11d5f6e7493898f02690a859a467a7e9abc Mon Sep 17 00:00:00 2001 From: Esau Date: Thu, 21 Mar 2024 00:48:50 +0100 Subject: [PATCH 11/15] fix --- yarn-project/end-to-end/src/e2e_static_calls.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yarn-project/end-to-end/src/e2e_static_calls.test.ts b/yarn-project/end-to-end/src/e2e_static_calls.test.ts index 974d3ce3f45..411ac53c449 100644 --- a/yarn-project/end-to-end/src/e2e_static_calls.test.ts +++ b/yarn-project/end-to-end/src/e2e_static_calls.test.ts @@ -22,6 +22,7 @@ describe('e2e_static_calls', () => { describe('parent calls child', () => { it('performs legal private to private static calls', async () => { + await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); await parentContract.methods .privateStaticCall(childContract.address, childContract.methods.privateGetValue.selector, [ 42n, @@ -32,6 +33,7 @@ describe('e2e_static_calls', () => { }, 100_000); it('performs legal (nested) private to private static calls', async () => { + await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); await parentContract.methods .privateStaticCallNested(childContract.address, childContract.methods.privateGetValue.selector, [ 42n, From 48c56c6120ba4ca2877e0933b07d6bf3701ff378 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Thu, 21 Mar 2024 17:30:56 +0000 Subject: [PATCH 12/15] comments --- .../src/e2e_pending_note_hashes_contract.test.ts | 8 ++++++-- yarn-project/end-to-end/src/e2e_static_calls.test.ts | 4 ++++ .../simulator/src/client/private_execution.test.ts | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index 4f8cc56b7ac..e49297bd319 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -82,7 +82,9 @@ describe('e2e_pending_note_hashes_contract', () => { ) .send() .wait(); - await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); + await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( + `Assertion failed: Cannot return zero notes 'num_notes != 0'` + ); await expectNoteHashesSquashedExcept(0); await expectNullifiersSquashedExcept(0); @@ -157,7 +159,9 @@ describe('e2e_pending_note_hashes_contract', () => { ) .send() .wait(); - await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow(); + await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( + `Assertion failed: Cannot return zero notes 'num_notes != 0'` + ); // second TX creates 1 note, but it is squashed! await expectNoteHashesSquashedExcept(0); diff --git a/yarn-project/end-to-end/src/e2e_static_calls.test.ts b/yarn-project/end-to-end/src/e2e_static_calls.test.ts index 411ac53c449..6461ce22a6f 100644 --- a/yarn-project/end-to-end/src/e2e_static_calls.test.ts +++ b/yarn-project/end-to-end/src/e2e_static_calls.test.ts @@ -22,7 +22,9 @@ describe('e2e_static_calls', () => { describe('parent calls child', () => { it('performs legal private to private static calls', async () => { + // We create a note in the set, so... await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); + // ...this call doesn't fail due to get_notes returning 0 notes await parentContract.methods .privateStaticCall(childContract.address, childContract.methods.privateGetValue.selector, [ 42n, @@ -33,7 +35,9 @@ describe('e2e_static_calls', () => { }, 100_000); it('performs legal (nested) private to private static calls', async () => { + // We create a note in the set, so... await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); + // ...this call doesn't fail due to get_notes returning 0 notes await parentContract.methods .privateStaticCallNested(childContract.address, childContract.methods.privateGetValue.selector, [ 42n, diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 6a2117e0fff..db6404a8aa2 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -996,7 +996,9 @@ describe('Private Execution test suite', () => { artifact: artifact, contractAddress, }), - ).rejects.toThrow(); + ).rejects.toThrow( + `Assertion failed: Cannot return zero notes 'num_notes != 0'` + ); }); }); @@ -1024,7 +1026,9 @@ describe('Private Execution test suite', () => { const args = [2n, true]; oracle.getNotes.mockResolvedValue([]); - await expect(runSimulator({ artifact, args })).rejects.toThrow(); + await expect(runSimulator({ artifact, args })).rejects.toThrow( + `Assertion failed: Cannot return zero notes 'num_notes != 0'` + ); }); }); From a8c997139b8fdfb4c64d53bd51dc0b75594f3a68 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Thu, 21 Mar 2024 17:41:41 +0000 Subject: [PATCH 13/15] yarn format --- .../end-to-end/src/e2e_pending_note_hashes_contract.test.ts | 4 ++-- yarn-project/simulator/src/client/private_execution.test.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index e49297bd319..03dd0f27a9e 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -83,7 +83,7 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'` + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); await expectNoteHashesSquashedExcept(0); @@ -160,7 +160,7 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'` + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); // second TX creates 1 note, but it is squashed! diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index db6404a8aa2..4293e611a16 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -996,9 +996,7 @@ describe('Private Execution test suite', () => { artifact: artifact, contractAddress, }), - ).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'` - ); + ).rejects.toThrow(`Assertion failed: Cannot return zero notes 'num_notes != 0'`); }); }); @@ -1027,7 +1025,7 @@ describe('Private Execution test suite', () => { oracle.getNotes.mockResolvedValue([]); await expect(runSimulator({ artifact, args })).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'` + `Assertion failed: Cannot return zero notes 'num_notes != 0'`, ); }); }); From 1326bd401b699174b6b1207fa299a748132c7711 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Thu, 21 Mar 2024 19:19:27 +0000 Subject: [PATCH 14/15] fix --- .../end-to-end/src/e2e_blacklist_token_contract.test.ts | 2 +- yarn-project/end-to-end/src/e2e_card_game.test.ts | 2 +- yarn-project/end-to-end/src/e2e_note_getter.test.ts | 2 +- .../end-to-end/src/e2e_pending_note_hashes_contract.test.ts | 4 ++-- yarn-project/end-to-end/src/e2e_token_contract.test.ts | 2 +- yarn-project/simulator/src/client/private_execution.test.ts | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts index 310a183fc30..efb35e65902 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts @@ -389,7 +389,7 @@ describe('e2e_blacklist_token_contract', () => { getMembershipCapsule(await getMembershipProof(accounts[0].address.toBigInt(), true)), ); await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); }); diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/e2e_card_game.test.ts index 6fa22829dd2..1520f91c92a 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/e2e_card_game.test.ts @@ -172,7 +172,7 @@ describe('e2e_card_game', () => { .join_game(GAME_ID, [cardToField(firstPlayerCollection[0]), cardToField(firstPlayerCollection[1])]) .send() .wait(), - ).rejects.toThrow(`Assertion failed: Cannot return zero notes 'num_notes != 0'`); + ).rejects.toThrow(`Assertion failed: Cannot return zero notes`); const collection = await contract.methods.view_collection_cards(firstPlayer, 0).view({ from: firstPlayer }); expect(unwrapOptions(collection)).toHaveLength(1); diff --git a/yarn-project/end-to-end/src/e2e_note_getter.test.ts b/yarn-project/end-to-end/src/e2e_note_getter.test.ts index acf60b61818..402b50f5b05 100644 --- a/yarn-project/end-to-end/src/e2e_note_getter.test.ts +++ b/yarn-project/end-to-end/src/e2e_note_getter.test.ts @@ -176,7 +176,7 @@ describe('e2e_note_getter', () => { async function assertNoReturnValue(storageSlot: number, activeOrNullified: boolean) { await expect(contract.methods.call_view_notes(storageSlot, activeOrNullified).view()).rejects.toThrow('is_some'); await expect(contract.methods.call_get_notes(storageSlot, activeOrNullified).send().wait()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); } diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index 03dd0f27a9e..1e30daec290 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -83,7 +83,7 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); await expectNoteHashesSquashedExcept(0); @@ -160,7 +160,7 @@ describe('e2e_pending_note_hashes_contract', () => { .send() .wait(); await expect(deployedContract.methods.get_note_zero_balance(owner).send().wait()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); // second TX creates 1 note, but it is squashed! diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index e7f5a7b51b0..f7e60748f2e 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -275,7 +275,7 @@ describe('e2e_token_contract', () => { 'The note has been destroyed.', ); await expect(asset.methods.redeem_shield(accounts[0].address, amount, secret).simulate()).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); }); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 4293e611a16..797ed6edd32 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -996,7 +996,7 @@ describe('Private Execution test suite', () => { artifact: artifact, contractAddress, }), - ).rejects.toThrow(`Assertion failed: Cannot return zero notes 'num_notes != 0'`); + ).rejects.toThrow(`Assertion failed: Cannot return zero notes`); }); }); @@ -1025,7 +1025,7 @@ describe('Private Execution test suite', () => { oracle.getNotes.mockResolvedValue([]); await expect(runSimulator({ artifact, args })).rejects.toThrow( - `Assertion failed: Cannot return zero notes 'num_notes != 0'`, + `Assertion failed: Cannot return zero notes`, ); }); }); From 6939c8f6e80b58db96bedbb2f660593535bf6d44 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Thu, 21 Mar 2024 19:37:36 +0000 Subject: [PATCH 15/15] format --- yarn-project/simulator/src/client/private_execution.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 797ed6edd32..32b6d1f8b86 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -1024,9 +1024,7 @@ describe('Private Execution test suite', () => { const args = [2n, true]; oracle.getNotes.mockResolvedValue([]); - await expect(runSimulator({ artifact, args })).rejects.toThrow( - `Assertion failed: Cannot return zero notes`, - ); + await expect(runSimulator({ artifact, args })).rejects.toThrow(`Assertion failed: Cannot return zero notes`); }); });