From 0543bd2382b8ff9ee0783df10284bc5e7ffdb836 Mon Sep 17 00:00:00 2001 From: superstar0402 Date: Wed, 6 Sep 2023 10:07:06 -0300 Subject: [PATCH] feat(docs): Testing guide and getPrivateStorage method (#1992) 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 https://github.com/AztecProtocol/aztec-packages/issues/2009) - [x] Add documentation test suite to CI as yet another e2e - [x] Add `getPrivateStorageAt` to cheat codes Depends on #1991 --- yarn-project/noir-libs/value-note/src/utils.nr | 2 +- yarn-project/noir-libs/value-note/src/value_note.nr | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/yarn-project/noir-libs/value-note/src/utils.nr b/yarn-project/noir-libs/value-note/src/utils.nr index 13e1d42..f431895 100644 --- a/yarn-project/noir-libs/value-note/src/utils.nr +++ b/yarn-project/noir-libs/value-note/src/utils.nr @@ -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. diff --git a/yarn-project/noir-libs/value-note/src/value_note.nr b/yarn-project/noir-libs/value-note/src/value_note.nr index 79f0213..b4b79c1 100644 --- a/yarn-project/noir-libs/value-note/src/value_note.nr +++ b/yarn-project/noir-libs/value-note/src/value_note.nr @@ -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 {