@@ -52,7 +52,7 @@ async fn create_mint_and_token_account(
52
52
}
53
53
54
54
#[ tokio:: test]
55
- async fn test_stake_pool_initialize ( ) {
55
+ async fn success_initialize ( ) {
56
56
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
57
57
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
58
58
stake_pool_accounts
@@ -77,7 +77,7 @@ async fn test_stake_pool_initialize() {
77
77
}
78
78
79
79
#[ tokio:: test]
80
- async fn test_initialize_already_initialized_stake_pool ( ) {
80
+ async fn fail_double_initialize ( ) {
81
81
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
82
82
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
83
83
stake_pool_accounts
@@ -108,7 +108,7 @@ async fn test_initialize_already_initialized_stake_pool() {
108
108
}
109
109
110
110
#[ 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 ( ) {
112
112
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
113
113
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
114
114
stake_pool_accounts
@@ -139,7 +139,7 @@ async fn test_initialize_stake_pool_with_already_initialized_stake_list_storage(
139
139
}
140
140
141
141
#[ tokio:: test]
142
- async fn test_initialize_stake_pool_with_high_fee ( ) {
142
+ async fn fail_initialize_with_high_fee ( ) {
143
143
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
144
144
let mut stake_pool_accounts = StakePoolAccounts :: new ( ) ;
145
145
stake_pool_accounts. fee = instruction:: Fee {
@@ -165,7 +165,7 @@ async fn test_initialize_stake_pool_with_high_fee() {
165
165
}
166
166
167
167
#[ tokio:: test]
168
- async fn test_initialize_stake_pool_with_wrong_max_validators ( ) {
168
+ async fn fail_initialize_with_wrong_max_validators ( ) {
169
169
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
170
170
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
171
171
@@ -245,7 +245,7 @@ async fn test_initialize_stake_pool_with_wrong_max_validators() {
245
245
}
246
246
247
247
#[ tokio:: test]
248
- async fn test_initialize_stake_pool_with_wrong_mint_authority ( ) {
248
+ async fn fail_initialize_with_wrong_mint_authority ( ) {
249
249
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
250
250
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
251
251
let wrong_mint = Keypair :: new ( ) ;
@@ -299,7 +299,7 @@ async fn test_initialize_stake_pool_with_wrong_mint_authority() {
299
299
}
300
300
301
301
#[ tokio:: test]
302
- async fn test_initialize_stake_pool_with_wrong_token_program_id ( ) {
302
+ async fn fail_initialize_with_wrong_token_program_id ( ) {
303
303
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
304
304
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
305
305
@@ -399,7 +399,7 @@ async fn test_initialize_stake_pool_with_wrong_token_program_id() {
399
399
}
400
400
401
401
#[ tokio:: test]
402
- async fn test_initialize_stake_pool_with_wrong_fee_accounts_manager ( ) {
402
+ async fn fail_initialize_with_wrong_fee_account ( ) {
403
403
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
404
404
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
405
405
@@ -446,24 +446,17 @@ async fn test_initialize_stake_pool_with_wrong_fee_accounts_manager() {
446
446
)
447
447
. await
448
448
. err ( )
449
+ . unwrap ( )
449
450
. unwrap ( ) ;
450
451
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
+ ) ;
463
456
}
464
457
465
458
#[ tokio:: test]
466
- async fn test_initialize_stake_pool_with_wrong_withdraw_authority ( ) {
459
+ async fn fail_initialize_with_wrong_withdraw_authority ( ) {
467
460
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
468
461
let mut stake_pool_accounts = StakePoolAccounts :: new ( ) ;
469
462
@@ -490,7 +483,7 @@ async fn test_initialize_stake_pool_with_wrong_withdraw_authority() {
490
483
}
491
484
492
485
#[ tokio:: test]
493
- async fn test_initialize_stake_pool_with_not_rent_exempt_pool ( ) {
486
+ async fn fail_initialize_with_not_rent_exempt_pool ( ) {
494
487
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
495
488
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
496
489
@@ -563,7 +556,7 @@ async fn test_initialize_stake_pool_with_not_rent_exempt_pool() {
563
556
}
564
557
565
558
#[ 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 ( ) {
567
560
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
568
561
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
569
562
@@ -638,7 +631,7 @@ async fn test_initialize_stake_pool_with_not_rent_exempt_validator_list() {
638
631
}
639
632
640
633
#[ tokio:: test]
641
- async fn test_initialize_stake_pool_without_manager_signature ( ) {
634
+ async fn fail_initialize_without_manager_signature ( ) {
642
635
let ( mut banks_client, payer, recent_blockhash) = program_test ( ) . start ( ) . await ;
643
636
let stake_pool_accounts = StakePoolAccounts :: new ( ) ;
644
637
@@ -727,3 +720,71 @@ async fn test_initialize_stake_pool_without_manager_signature() {
727
720
) ,
728
721
}
729
722
}
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