Skip to content

Conversation

@rustopian
Copy link

@rustopian rustopian commented Nov 4, 2025

Part 1 of https://github.com/orgs/solana-program/projects/8.

Problem

solana-program-test is on its slow way out.

Solution

Convert these tests to Mollusk, including simple but perfectly equivalent stake tracking.

This part migrates Initialize and InitializeChecked tests, 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:

  • Add simple StakeTestContext and InstructionConfig builder pattern
  • Migrate Initialize tests to mollusk, out of program_test.rs to initialize.rs
  • Start relocation of StakeLifecycle management to a helper file
  • test_case is used to run all Initialize tests against InitializeChecked as well
  • added wrong owner test
  • Improve test safety: every instruction runs test_missing_signers unless this is explicitly set to false

This does NOT migrate tests from the newer stake_instruction.rs, which already uses Mollusk.

@rustopian rustopian force-pushed the mollusk-1-initialize branch from 2ab4655 to c2acd67 Compare November 4, 2025 11:42
@rustopian rustopian requested a review from grod220 November 4, 2025 12:37
Comment on lines +28 to +33
pub struct StakeTestContext {
pub mollusk: Mollusk,
pub rent_exempt_reserve: u64,
pub staker: Pubkey,
pub withdrawer: Pubkey,
}
Copy link
Author

@rustopian rustopian Nov 4, 2025

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

Comment on lines +20 to +28
pub fn create_uninitialized_account(self) -> AccountSharedData {
AccountSharedData::new_data_with_space(
STAKE_RENT_EXEMPTION,
&StakeStateV2::Uninitialized,
StakeStateV2::size_of(),
&id(),
)
.unwrap()
}
Copy link
Author

@rustopian rustopian Nov 4, 2025

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);
Copy link
Author

@rustopian rustopian Nov 4, 2025

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.

@rustopian rustopian marked this pull request as ready for review November 4, 2025 13:01
@@ -0,0 +1,7 @@
#![allow(clippy::arithmetic_side_effects)]
#![allow(dead_code)]
Copy link
Author

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.

@rustopian
Copy link
Author

rustopian commented Nov 13, 2025

Taking back to draft pending a few small updates based on discussions in Rome

@rustopian rustopian marked this pull request as draft November 13, 2025 20:18
@rustopian rustopian changed the title Mollusk 1/9: InstructionConfig, Initialize tests tests: Mollusk InstructionConfig, Initialize tests (1/9) Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant