Skip to content

[NOT FOR MERGING] Migrate solana-program-test tests to Mollusk#139

Closed
rustopian wants to merge 14 commits intomainfrom
convert-tests-to-mollusk
Closed

[NOT FOR MERGING] Migrate solana-program-test tests to Mollusk#139
rustopian wants to merge 14 commits intomainfrom
convert-tests-to-mollusk

Conversation

@rustopian
Copy link
Contributor

@rustopian rustopian commented Oct 21, 2025

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:

  1. Codama approach and one demonstrative test file
  2. StakeTracker and another demonstrative test file
  3. Remaining test file(s)

Initially this PR used some on-demand StakeHistory sysvar writing, but it proved cleaned and more reliable to implement a simple trait MolluskStakeExt with a StakeTracker which 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.

@rustopian rustopian requested a review from grod220 October 21, 2025 13:42
@rustopian rustopian changed the title [WIP] Migrate solana-program-test tests to Mollusk Migrate solana-program-test tests to Mollusk Oct 21, 2025
Copy link
Member

@grod220 grod220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like the new patterns (chef's kiss), well done!

  • Can we delete the solana-program-test dep 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

@rustopian rustopian Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Comment on lines 951 to 952
pub vote_account: Pubkey,
pub vote_account_data: AccountSharedData,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these should be a tuple (?)

Pubkey::new_unique(), // Synthetic background stake pubkey
TrackedDelegation {
stake: background_stake,
activation_epoch: u64::MAX, // Bootstrap = instantly effective
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so familiar with this mechanic, but wouldn't activation epoch of 0 make more sense?

Comment on lines 481 to 494
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();
Copy link
Member

@grod220 grod220 Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this should be a method of StakeTestContext that returns Self. Max buildoorrrr pattern.

@rustopian rustopian force-pushed the convert-tests-to-mollusk branch 2 times, most recently from 0e5a9ce to 2f37986 Compare October 30, 2025 13:41
@rustopian rustopian force-pushed the convert-tests-to-mollusk branch from bd12914 to d270ab6 Compare October 30, 2025 14:07
@rustopian rustopian changed the title Migrate solana-program-test tests to Mollusk [NOT FOR MERGING] Migrate solana-program-test tests to Mollusk Oct 31, 2025
@rustopian rustopian closed this Nov 3, 2025
@rustopian rustopian deleted the convert-tests-to-mollusk branch December 9, 2025 10:19
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.

2 participants