Skip to content

Commit

Permalink
chore: update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Jul 3, 2024
1 parent c9e7990 commit 540121b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ impl<T> BalancesMap<T, &mut PrivateContext> {
subtrahend: U128,
limit: u32
) -> (U128, U128) where T: NoteInterface<T_SERIALIZED_LEN, T_SERIALIZED_BYTES_LEN> + OwnedNote {
// docs:start:get_notes
let options = NoteGetterOptions::with_filter(filter_notes_min_sum, subtrahend).set_limit(limit);
let notes = self.map.at(owner).get_notes(options);
// docs:end:get_notes

assert(notes.len() > 0, "No notes found");

Expand All @@ -136,9 +134,7 @@ impl<T> BalancesMap<T, &mut PrivateContext> {
// This will call the the `compute_nullifer` function of the `token_note`
// which require knowledge of the secret key (currently the users encryption key).
// The contract logic must ensure that the spending key is used as well.
// docs:start:remove
self.map.at(owner).remove(note);
// docs:end:remove

minuend = minuend + note.get_amount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('e2e_token_contract transfer private', () => {
const amount = balance0 + 1n;
expect(amount).toBeGreaterThan(0n);
await expect(asset.methods.transfer(accounts[1].address, amount).simulate()).rejects.toThrow(
'Assertion failed: Balance too low',
"Assertion failed: Cannot return zero notes 'returned_notes.len() != 0'",
);
});

Expand Down
8 changes: 6 additions & 2 deletions yarn-project/end-to-end/src/guides/dapp_testing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,18 @@ describe('guides/dapp/testing', () => {
it('asserts a local transaction simulation fails by calling simulate', async () => {
// docs:start:local-tx-fails
const call = token.methods.transfer(recipient.getAddress(), 200n);
await expect(call.prove()).rejects.toThrow(/Balance too low/);
await expect(call.prove()).rejects.toThrow(
"Assertion failed: Cannot return zero notes 'returned_notes.len() != 0'",
);
// docs:end:local-tx-fails
});

it('asserts a local transaction simulation fails by calling send', async () => {
// docs:start:local-tx-fails-send
const call = token.methods.transfer(recipient.getAddress(), 200n);
await expect(call.send().wait()).rejects.toThrow(/Balance too low/);
await expect(call.send().wait()).rejects.toThrow(
"Assertion failed: Cannot return zero notes 'returned_notes.len() != 0'",
);
// docs:end:local-tx-fails-send
});

Expand Down

0 comments on commit 540121b

Please sign in to comment.