Closed Ikrk closed 8 months ago
The accounts snapshots code generation was changed and the tests do not pass anymore. I will correct it next week.
When used on fuzz_example3, the freshly generated account_snapshots.rs contains an error for "escrow_pda_authority". The account is expected to be:
However, the code is generated as: let escrow_pda_authority = accounts_iter .next() .ok_or(FuzzingError::NotEnoughAccounts)?;
where escrow_pdaauthority has type Option<AccountInfo<'>>
I made some additional testing today and so far I found another issues:
EDIT: I was further testing account types based on anchor_lang::accounts for Anchor 0.28.0, and my suggestions/observations:
Finally I have made following modifications:
Good job ! I did some testing and it looks like everything generates correctly.
Added support for all Anchor types. Now, any context structure supported by Anchor 0.29.0 should be correctly parsed and the appropriate snapshot structs generated correctly.
Before this change, the parsing was done "manually". Now however we are using the parser directly from Anchor that has been exposed in Anchor 0.29.0 when using the idl-build feature flag. The types
Interface
andInterfaceAccount
were not tested.Also, this PR changes the way how the snapshot accounts are constructed. Now only the explicitly optional accounts and the accounts that have the
init
orclose
constraints are wrapped into the Option type. That make the work with accounts within thecheck
methods easier because it is not necessary to always verify if there is Some account.Finally, this PR modularized the implementation within the snapshot_generator.rs file to make it more readable.