diff --git a/Cargo.lock b/Cargo.lock index 30729d6ab7dc08..7529c46f934950 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6586,6 +6586,7 @@ dependencies = [ "solana-sdk", "solana-stake-program", "solana-vote-program", + "test-case", "thiserror", "tokio", ] diff --git a/program-test/Cargo.toml b/program-test/Cargo.toml index 07e05e88fb0ab1..9b8279fd1eab5c 100644 --- a/program-test/Cargo.toml +++ b/program-test/Cargo.toml @@ -29,6 +29,7 @@ solana-sdk = { workspace = true } solana-vote-program = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } +test-case = { workspace = true } [dev-dependencies] solana-stake-program = { workspace = true } diff --git a/program-test/tests/stake.rs b/program-test/tests/stake.rs index 70bbef3ed135e1..16c94cfdec2131 100644 --- a/program-test/tests/stake.rs +++ b/program-test/tests/stake.rs @@ -11,6 +11,7 @@ use { stake::{instruction as stake_instruction, instruction::StakeError}, transaction::{Transaction, TransactionError}, }, + test_case::test_case, }; #[derive(PartialEq)] @@ -20,6 +21,10 @@ enum PendingStakeActivationTestFlag { NoMerge, } +#[test_case(PendingStakeActivationTestFlag::NoMerge; "test that redelegate stake then deactivate it then withdraw from it is not permitted")] +#[test_case(PendingStakeActivationTestFlag::MergeActive; "test that redelegate stake then merge with another active stake then deactivate it then withdraw from it is not permitted")] +#[test_case(PendingStakeActivationTestFlag::MergeInactive; "test that redelegate stake then merge with another inactive stake then deactivate it then withdraw from it is not permitted")] +#[tokio::test] async fn test_stake_redelegation_pending_activation(merge_flag: PendingStakeActivationTestFlag) { let program_test = ProgramTest::default(); let mut context = program_test.start_with_context().await; @@ -186,18 +191,3 @@ async fn test_stake_redelegation_pending_activation(merge_flag: PendingStakeActi .await .unwrap(); } - -#[tokio::test] -async fn test_stake_redelegation_then_deactivation_withdraw_not_permitted() { - test_stake_redelegation_pending_activation(PendingStakeActivationTestFlag::NoMerge).await -} - -#[tokio::test] -async fn test_stake_redelegation_then_merge_active_then_deactivation_withdraw_not_permitted() { - test_stake_redelegation_pending_activation(PendingStakeActivationTestFlag::MergeActive).await -} - -#[tokio::test] -async fn test_stake_redelegation_then_merge_inactive_then_deactivation_withdraw_not_permitted() { - test_stake_redelegation_pending_activation(PendingStakeActivationTestFlag::MergeInactive).await -} diff --git a/program-test/tests/warp.rs b/program-test/tests/warp.rs index 3d7be785bf7b12..da0b632ad66759 100644 --- a/program-test/tests/warp.rs +++ b/program-test/tests/warp.rs @@ -30,7 +30,7 @@ use { transaction::{Transaction, TransactionError}, }, solana_stake_program::stake_state, - solana_vote_program::vote_state::{self}, + solana_vote_program::vote_state, std::convert::TryInto, };