Skip to content
Merged
3 changes: 3 additions & 0 deletions noir-projects/aztec-nr/aztec/src/note/note_getter.nr
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ pub fn get_notes<Note, N, FILTER_ARGS>(
if options.limit != 0 {
assert(num_notes <= options.limit, "Invalid number of return notes.");
}

assert(num_notes != 0, "Cannot return zero notes");

opt_notes
}

Expand Down
11 changes: 11 additions & 0 deletions yarn-project/simulator/src/client/private_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,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();
Expand Down