diff --git a/Cargo.lock b/Cargo.lock index 7218a80cb1c4ba..11b687ef77c962 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6587,6 +6587,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..87a9c88487a30d 100644 --- a/program-test/Cargo.toml +++ b/program-test/Cargo.toml @@ -27,6 +27,7 @@ solana-program-runtime = { workspace = true } solana-runtime = { workspace = true } solana-sdk = { workspace = true } solana-vote-program = { workspace = true } +test-case = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } diff --git a/program-test/tests/stake.rs b/program-test/tests/stake.rs index 70bbef3ed135e1..b0e371b9621d69 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 it with another active stake then deactivate it then withdraw from it is not permitted")] +#[test_case(PendingStakeActivationTestFlag::MergeInactive; "test that redelegate stake then merge it 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, }; diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 8863bef090ed83..d6fbe9f6f79707 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5331,6 +5331,7 @@ dependencies = [ "solana-runtime", "solana-sdk", "solana-vote-program", + "test-case", "thiserror", "tokio", ] @@ -6828,6 +6829,41 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "test-case" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" +dependencies = [ + "test-case-macros", +] + +[[package]] +name = "test-case-core" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "test-case-macros" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.37", + "test-case-core", +] + [[package]] name = "textwrap" version = "0.11.0"