@@ -52,7 +52,7 @@ async fn create_mint_and_token_account(
5252}
5353
5454#[ tokio:: test]
55- async fn test_stake_pool_initialize ( ) {
55+ async fn success_initialize ( ) {
5656 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
5757 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
5858 stake_pool_accounts
@@ -77,7 +77,7 @@ async fn test_stake_pool_initialize() {
7777}
7878
7979#[ tokio:: test]
80- async fn test_initialize_already_initialized_stake_pool ( ) {
80+ async fn fail_double_initialize ( ) {
8181 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
8282 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
8383 stake_pool_accounts
@@ -108,7 +108,7 @@ async fn test_initialize_already_initialized_stake_pool() {
108108}
109109
110110#[ tokio:: test]
111- async fn test_initialize_stake_pool_with_already_initialized_stake_list_storage ( ) {
111+ async fn fail_initialize_with_already_initialized_validator_list ( ) {
112112 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
113113 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
114114 stake_pool_accounts
@@ -139,7 +139,7 @@ async fn test_initialize_stake_pool_with_already_initialized_stake_list_storage(
139139}
140140
141141#[ tokio:: test]
142- async fn test_initialize_stake_pool_with_high_fee ( ) {
142+ async fn fail_initialize_with_high_fee ( ) {
143143 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
144144 let mut stake_pool_accounts = StakePoolAccounts :: new ( ) ;
145145 stake_pool_accounts. fee = instruction:: Fee {
@@ -165,7 +165,7 @@ async fn test_initialize_stake_pool_with_high_fee() {
165165}
166166
167167#[ tokio:: test]
168- async fn test_initialize_stake_pool_with_wrong_max_validators ( ) {
168+ async fn fail_initialize_with_wrong_max_validators ( ) {
169169 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
170170 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
171171
@@ -245,7 +245,7 @@ async fn test_initialize_stake_pool_with_wrong_max_validators() {
245245}
246246
247247#[ tokio:: test]
248- async fn test_initialize_stake_pool_with_wrong_mint_authority ( ) {
248+ async fn fail_initialize_with_wrong_mint_authority ( ) {
249249 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
250250 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
251251 let wrong_mint = Keypair :: new ( ) ;
@@ -299,7 +299,7 @@ async fn test_initialize_stake_pool_with_wrong_mint_authority() {
299299}
300300
301301#[ tokio:: test]
302- async fn test_initialize_stake_pool_with_wrong_token_program_id ( ) {
302+ async fn fail_initialize_with_wrong_token_program_id ( ) {
303303 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
304304 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
305305
@@ -399,7 +399,7 @@ async fn test_initialize_stake_pool_with_wrong_token_program_id() {
399399}
400400
401401#[ tokio:: test]
402- async fn test_initialize_stake_pool_with_wrong_fee_accounts_manager ( ) {
402+ async fn fail_initialize_with_wrong_fee_account ( ) {
403403 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
404404 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
405405
@@ -446,24 +446,17 @@ async fn test_initialize_stake_pool_with_wrong_fee_accounts_manager() {
446446 )
447447 . await
448448 . err ( )
449+ . unwrap ( )
449450 . unwrap ( ) ;
450451
451- match transaction_error {
452- TransportError :: TransactionError ( TransactionError :: InstructionError (
453- _,
454- InstructionError :: Custom ( error_index) ,
455- ) ) => {
456- let program_error = error:: StakePoolError :: InvalidFeeAccount as u32 ;
457- assert_eq ! ( error_index, program_error) ;
458- }
459- _ => panic ! (
460- "Wrong error occurs while try to initialize stake pool with wrong fee account's manager"
461- ) ,
462- }
452+ assert_eq ! (
453+ transaction_error,
454+ TransactionError :: InstructionError ( 2 , InstructionError :: IncorrectProgramId )
455+ ) ;
463456}
464457
465458#[ tokio:: test]
466- async fn test_initialize_stake_pool_with_wrong_withdraw_authority ( ) {
459+ async fn fail_initialize_with_wrong_withdraw_authority ( ) {
467460 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
468461 let mut stake_pool_accounts = StakePoolAccounts :: new ( ) ;
469462
@@ -490,7 +483,7 @@ async fn test_initialize_stake_pool_with_wrong_withdraw_authority() {
490483}
491484
492485#[ tokio:: test]
493- async fn test_initialize_stake_pool_with_not_rent_exempt_pool ( ) {
486+ async fn fail_initialize_with_not_rent_exempt_pool ( ) {
494487 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
495488 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
496489
@@ -563,7 +556,7 @@ async fn test_initialize_stake_pool_with_not_rent_exempt_pool() {
563556}
564557
565558#[ tokio:: test]
566- async fn test_initialize_stake_pool_with_not_rent_exempt_validator_list ( ) {
559+ async fn fail_initialize_with_not_rent_exempt_validator_list ( ) {
567560 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
568561 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
569562
@@ -638,7 +631,7 @@ async fn test_initialize_stake_pool_with_not_rent_exempt_validator_list() {
638631}
639632
640633#[ tokio:: test]
641- async fn test_initialize_stake_pool_without_manager_signature ( ) {
634+ async fn fail_initialize_without_manager_signature ( ) {
642635 let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
643636 let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
644637
@@ -727,3 +720,71 @@ async fn test_initialize_stake_pool_without_manager_signature() {
727720 ) ,
728721 }
729722}
723+
724+ #[ tokio:: test]
725+ async fn fail_initialize_with_pre_minted_pool_tokens ( ) {
726+ let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
727+ let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
728+ let mint_authority = Keypair :: new ( ) ;
729+
730+ create_mint (
731+ & mut banks_client,
732+ & payer,
733+ & recent_blockhash,
734+ & stake_pool_accounts. pool_mint ,
735+ & mint_authority. pubkey ( ) ,
736+ )
737+ . await
738+ . unwrap ( ) ;
739+
740+ create_token_account (
741+ & mut banks_client,
742+ & payer,
743+ & recent_blockhash,
744+ & stake_pool_accounts. pool_fee_account ,
745+ & stake_pool_accounts. pool_mint . pubkey ( ) ,
746+ & stake_pool_accounts. manager . pubkey ( ) ,
747+ )
748+ . await
749+ . unwrap ( ) ;
750+
751+ mint_tokens (
752+ & mut banks_client,
753+ & payer,
754+ & recent_blockhash,
755+ & stake_pool_accounts. pool_mint . pubkey ( ) ,
756+ & stake_pool_accounts. pool_fee_account . pubkey ( ) ,
757+ & mint_authority,
758+ 1 ,
759+ )
760+ . await
761+ . unwrap ( ) ;
762+
763+ let transaction_error = create_stake_pool (
764+ & mut banks_client,
765+ & payer,
766+ & recent_blockhash,
767+ & stake_pool_accounts. stake_pool ,
768+ & stake_pool_accounts. validator_list ,
769+ & stake_pool_accounts. pool_mint . pubkey ( ) ,
770+ & stake_pool_accounts. pool_fee_account . pubkey ( ) ,
771+ & stake_pool_accounts. manager ,
772+ & stake_pool_accounts. staker . pubkey ( ) ,
773+ & stake_pool_accounts. fee ,
774+ stake_pool_accounts. max_validators ,
775+ )
776+ . await
777+ . err ( )
778+ . unwrap ( ) ;
779+
780+ match transaction_error {
781+ TransportError :: TransactionError ( TransactionError :: InstructionError (
782+ _,
783+ InstructionError :: Custom ( error_index) ,
784+ ) ) => {
785+ let program_error = error:: StakePoolError :: NonZeroPoolTokenSupply as u32 ;
786+ assert_eq ! ( error_index, program_error) ;
787+ }
788+ _ => panic ! ( "Wrong error occurs while try to initialize stake pool with wrong mint authority of pool fee account" ) ,
789+ }
790+ }
0 commit comments