-
Notifications
You must be signed in to change notification settings - Fork 30
tests: Mollusk InstructionConfig, Initialize tests (1/9) #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2ab4655 to
c2acd67
Compare
| pub struct StakeTestContext { | ||
| pub mollusk: Mollusk, | ||
| pub rent_exempt_reserve: u64, | ||
| pub staker: Pubkey, | ||
| pub withdrawer: Pubkey, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is extended in next PR, when the instructions being tested require it
| pub fn create_uninitialized_account(self) -> AccountSharedData { | ||
| AccountSharedData::new_data_with_space( | ||
| STAKE_RENT_EXEMPTION, | ||
| &StakeStateV2::Uninitialized, | ||
| StakeStateV2::size_of(), | ||
| &id(), | ||
| ) | ||
| .unwrap() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full lifecycle management is in next PR (Initialize tests don't need it)
| _ => &default_checks, | ||
| }; | ||
|
|
||
| let test_missing_signers = self.test_missing_signers.unwrap_or(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumed true, so tests must explicitly opt out with .test_missing_signers(false)
Meant to prevent a test from forgetting to test missing signers.
| @@ -0,0 +1,7 @@ | |||
| #![allow(clippy::arithmetic_side_effects)] | |||
| #![allow(dead_code)] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since test banks compile individually, we'll soon otherwise get dead_code warnings for any helpers which are not used in every single one.
|
Taking back to draft pending a few small updates based on discussions in Rome |
Part 1 of https://github.com/orgs/solana-program/projects/8.
Problem
solana-program-testis on its slow way out.Solution
Convert these tests to Mollusk, including simple but perfectly equivalent stake tracking.
This part migrates
InitializeandInitializeCheckedtests, and only includes helper utilities relevant to these tests. (Some lifecycle management and all stake history management is not yet required and is saved for later PRs.)Included:
StakeTestContextandInstructionConfigbuilder patternInitializetests to mollusk, out of program_test.rs to initialize.rsStakeLifecyclemanagement to a helper filetest_caseis used to run allInitializetests againstInitializeCheckedas welltest_missing_signersunless this is explicitly set tofalseThis does NOT migrate tests from the newer stake_instruction.rs, which already uses Mollusk.