diff --git a/staking/integration-tests/tests/integrity_pool_slash.rs b/staking/integration-tests/tests/integrity_pool_slash.rs index 433bcb15..7f725f06 100644 --- a/staking/integration-tests/tests/integrity_pool_slash.rs +++ b/staking/integration-tests/tests/integrity_pool_slash.rs @@ -313,17 +313,6 @@ fn test_slash() { post_dummy_publisher_caps(&mut svm, &payer, publisher_keypair.pubkey(), 50); advance(&mut svm, &payer, publisher_caps).unwrap(); - advance_delegation_record( - &mut svm, - &payer, - publisher_keypair.pubkey(), - stake_account_positions, - pyth_token_mint.pubkey(), - pool_data_pubkey, - None, - ) - .unwrap(); - // undelegate 2 PYTH at epoch N + 2 undelegate( &mut svm, @@ -373,6 +362,32 @@ fn test_slash() { } ); + assert_anchor_program_error!( + slash( + &mut svm, + &payer, + stake_account_positions, + 0, + slash_custody, + publisher_keypair.pubkey(), + pool_data_pubkey, + ), + IntegrityPoolError::OutdatedDelegatorAccounting, + 0 + ); + svm.expire_blockhash(); + + advance_delegation_record( + &mut svm, + &payer, + publisher_keypair.pubkey(), + stake_account_positions, + pyth_token_mint.pubkey(), + pool_data_pubkey, + None, + ) + .unwrap(); + assert_anchor_program_error!( slash( &mut svm, @@ -387,6 +402,7 @@ fn test_slash() { 0 ); + slash( &mut svm, &payer, diff --git a/staking/programs/integrity-pool/src/lib.rs b/staking/programs/integrity-pool/src/lib.rs index c111da6c..b396277b 100644 --- a/staking/programs/integrity-pool/src/lib.rs +++ b/staking/programs/integrity-pool/src/lib.rs @@ -409,6 +409,9 @@ pub mod integrity_pool { let current_epoch = get_current_epoch()?; + // assert delegator record is up to date + delegation_record.assert_up_to_date(current_epoch)?; + require_gte!( current_epoch, slash_event.epoch,