@@ -57,6 +57,7 @@ async fn setup(
57
57
& stake_pool_accounts. withdraw_authority ,
58
58
vote_account_address,
59
59
stake_amount,
60
+ StakeStatus :: Active ,
60
61
) ;
61
62
}
62
63
@@ -578,3 +579,62 @@ async fn withdraw() {
578
579
. await ;
579
580
assert ! ( error. is_none( ) , "{:?}" , error) ;
580
581
}
582
+
583
+ #[ tokio:: test]
584
+ async fn cleanup_all ( ) {
585
+ let mut program_test = program_test ( ) ;
586
+ let mut vote_account_pubkeys = vec ! [ ] ;
587
+ let mut stake_pool_accounts = StakePoolAccounts :: new ( ) ;
588
+ let max_validators = HUGE_POOL_SIZE ;
589
+ stake_pool_accounts. max_validators = max_validators;
590
+
591
+ let stake_pool_pubkey = stake_pool_accounts. stake_pool . pubkey ( ) ;
592
+ let ( mut stake_pool, mut validator_list) = stake_pool_accounts. state ( ) ;
593
+
594
+ for _ in 0 ..max_validators {
595
+ vote_account_pubkeys. push ( add_vote_account ( & mut program_test) ) ;
596
+ }
597
+
598
+ for vote_account_address in vote_account_pubkeys. iter ( ) {
599
+ add_validator_stake_account (
600
+ & mut program_test,
601
+ & mut stake_pool,
602
+ & mut validator_list,
603
+ & stake_pool_pubkey,
604
+ & stake_pool_accounts. withdraw_authority ,
605
+ vote_account_address,
606
+ STAKE_AMOUNT ,
607
+ StakeStatus :: ReadyForRemoval ,
608
+ ) ;
609
+ }
610
+
611
+ add_stake_pool_account (
612
+ & mut program_test,
613
+ & stake_pool_accounts. stake_pool . pubkey ( ) ,
614
+ & stake_pool,
615
+ ) ;
616
+ add_validator_list_account (
617
+ & mut program_test,
618
+ & stake_pool_accounts. validator_list . pubkey ( ) ,
619
+ & validator_list,
620
+ max_validators,
621
+ ) ;
622
+ let mut context = program_test. start_with_context ( ) . await ;
623
+
624
+ let transaction = Transaction :: new_signed_with_payer (
625
+ & [ instruction:: cleanup_removed_validator_entries (
626
+ & id ( ) ,
627
+ & stake_pool_accounts. stake_pool . pubkey ( ) ,
628
+ & stake_pool_accounts. validator_list . pubkey ( ) ,
629
+ ) ] ,
630
+ Some ( & context. payer . pubkey ( ) ) ,
631
+ & [ & context. payer ] ,
632
+ context. last_blockhash ,
633
+ ) ;
634
+ let error = context
635
+ . banks_client
636
+ . process_transaction ( transaction)
637
+ . await
638
+ . err ( ) ;
639
+ assert ! ( error. is_none( ) ) ;
640
+ }
0 commit comments