[NOT FOR MERGING] Migrate solana-program-test tests to Mollusk#139
[NOT FOR MERGING] Migrate solana-program-test tests to Mollusk#139
Conversation
grod220
left a comment
There was a problem hiding this comment.
Really like the new patterns (chef's kiss), well done!
- Can we delete the
solana-program-testdep in Cargo.toml? - Think breaking these down into separate PRs would be nice though. Would help the reviewer actually validate each test case has been migrated 1:1.
There was a problem hiding this comment.
Any thoughts on appending test_ to the test file names so they stand out from processor code that in the migration will be broken down by the same instruction name?
There was a problem hiding this comment.
Worth thinking about, but this breaks from patterns I've seen across our repos; IMO it's correct that the tests are just set off in their own folder /test/
program/tests/helpers.rs
Outdated
| pub vote_account: Pubkey, | ||
| pub vote_account_data: AccountSharedData, |
There was a problem hiding this comment.
Maybe these should be a tuple (?)
program/tests/helpers.rs
Outdated
| Pubkey::new_unique(), // Synthetic background stake pubkey | ||
| TrackedDelegation { | ||
| stake: background_stake, | ||
| activation_epoch: u64::MAX, // Bootstrap = instantly effective |
There was a problem hiding this comment.
I'm not so familiar with this mechanic, but wouldn't activation epoch of 0 make more sense?
program/tests/helpers.rs
Outdated
| pub fn initialize_stake_account( | ||
| mollusk: &Mollusk, | ||
| stake_pubkey: &Pubkey, | ||
| lamports: u64, | ||
| authorized: &Authorized, | ||
| lockup: &Lockup, | ||
| ) -> AccountSharedData { | ||
| let stake_account = AccountSharedData::new_data_with_space( | ||
| lamports, | ||
| &StakeStateV2::Uninitialized, | ||
| StakeStateV2::size_of(), | ||
| &id(), | ||
| ) | ||
| .unwrap(); |
There was a problem hiding this comment.
Wonder if this should be a method of StakeTestContext that returns Self. Max buildoorrrr pattern.
0e5a9ce to
2f37986
Compare
bd12914 to
d270ab6
Compare
Fully equivalent Mollusk tests, to replace the solana-program-test tests.
This monolithic working PR will be split into smaller PRs for easier reviewing and shepherding:
StakeTrackerand another demonstrative test fileInitially this PR used some on-demand StakeHistory sysvar writing, but it proved cleaned and more reliable to implement a simple
trait MolluskStakeExtwith aStakeTrackerwhich aggregates background delegation and any tracked delegations into StakeHistory entries when warping across epochs.A sizable amount of repetitive and fragile boilerplate code is reduced by using Codama-rendered instruction types and a generated, modified version of account arrays.