Skip to content

Commit

Permalink
feat(docs): Testing guide and getPrivateStorage method (#1992)
Browse files Browse the repository at this point in the history
Adds a guide on testing dapps. While writing the guide, I had to add a
`getPrivateStorageAt` method; but while reviewing other issues I noted
that this method already existed and was deleted on purpose, due to lack
of authentication.

I'd like to reincorporate the method, since it's useful for testing, and
we already lack authentication for accessing other private information
(like just calling `view` on a function that loads private notes) so we
are not opening a new avenue for attack.

- [x] Explain how to use sandbox pre-created accounts instead of
creating new ones (depends on #2002)
- [x] Extract utility function to spin up local node and show how to use
it
- [x] Set blockTimestamp to block object, add getBlock method to RPC
server, and use it to demo `warp` usage (extracted to
AztecProtocol/aztec-packages#2009)
- [x] Add documentation test suite to CI as yet another e2e
- [x] Add `getPrivateStorageAt` to cheat codes

Depends on #1991
  • Loading branch information
superstar0402 committed Sep 6, 2023
1 parent 764fc7a commit 0543bd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yarn-project/noir-libs/value-note/src/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn decrement(
owner: Field,
) {
let sum = decrement_by_at_most(balance, amount, owner);
assert(sum == amount);
assert(sum == amount, "Balance too low");
}

// Similar to `decrement`, except that it doesn't fail if the decremented amount is less than max_amount.
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/noir-libs/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ use dep::aztec::oracle::{

global VALUE_NOTE_LEN: Field = 3; // 3 plus a header.

// docs:start:value-note-def
struct ValueNote {
value: Field,
owner: Field,
randomness: Field,
header: NoteHeader,
}
// docs:end:value-note-def

impl ValueNote {
fn new(value: Field, owner: Field) -> Self {
Expand Down

0 comments on commit 0543bd2

Please sign in to comment.