test: Add the protocol fuzzer harness prototype#19628
Conversation
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
79cd2ad to
5bb54d4
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
LeilaWang
left a comment
There was a problem hiding this comment.
I'm not familiar with rust so can't comment on coding style or potential problem with how the code is written. I only looked at the high level and there might be a few things we can change :)
| BalanceOfPrivate { token, address, .. } => { | ||
| assert_eq!( | ||
| balance, | ||
| *pre_state.balances_public.get(&(*token, *address)).unwrap() |
There was a problem hiding this comment.
This should be balances_private?
| amount, | ||
| from, | ||
| } => { | ||
| if state.owners[token] == *from |
There was a problem hiding this comment.
Anyone with enough balance can transfer, not just the owner.
| } | ||
|
|
||
| fn check_result(&self, cmd: &Self::Command, pre_state: &Self::State, result: Self::Result) { | ||
| if let Ok(result) = result { |
There was a problem hiding this comment.
What if the result has error? Do we want to check that the failed command is expected?
| } | ||
|
|
||
| fn gen_token_amount(u: &mut Unstructured) -> arbitrary::Result<TokenAmount> { | ||
| Ok(u32::arbitrary(u)? as TokenAmount) |
There was a problem hiding this comment.
The amount is u128 in token contract.
| Self { | ||
| min_tokens: 1, | ||
| max_tokens: 4, | ||
| min_initial_public_mints: 1, |
There was a problem hiding this comment.
Wonder if mins should be 0s (and no command is made), so that we can test the scenarios where activities happen with uninitialized state.
There was a problem hiding this comment.
Mins can be zero I just felt the default scenario would be better left at 1 (or nothing would happen)
There was a problem hiding this comment.
Maybe nothing can happen (until a mint is done) is something we need to test 🤣
| assert_eq!( | ||
| balance, | ||
| *pre_state.balances_public.get(&(*token, *address)).unwrap() | ||
| *pre_state.balances_private.get(&(*token, *address)).unwrap() |
There was a problem hiding this comment.
I'm surprised this didn't cause any problem before. Maybe this doesn't get triggered at all. Is it possible the regex could be incorrect?
LeilaWang
left a comment
There was a problem hiding this comment.
Thanks for creating this!
a47ef43 to
180aea9
Compare
180aea9 to
e2f9056
Compare
This is a prototype fuzzing harness for Aztec contract interactions. At the moment, it utilizes
aztec-uptoolset present in the system to create several default token contracts with ownership randomly assigned to one of the threeaztec-uptest accounts, and then performs mint/burn/transfer operations over them (both private and public), keeping track of the supposed resulting balances in a state machine. The balances are also checked randomly, with the harness stopping with an assertion if they don't match the tracked values.It is currently in a PoW state and is supposed to become a base for testing validity of side effects and the like further on, through generation of custom contract methods with fuzzed inputs. For now it's probably early to include it in CI.