Skip to content

Commit

Permalink
Fix rebalance tests (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Batsell <[email protected]>
  • Loading branch information
coachchucksol and ebatsell authored Jul 23, 2024
1 parent 52ce4ff commit 4369738
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions tests/tests/steward/test_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,6 @@ async fn test_rebalance_increase() {
&serialized_stake_pool_account(stake_pool_spl, std::mem::size_of::<StakePool>()).into(),
);

let mut steward_state_account: StewardStateAccount =
fixture.load_and_deserialize(&fixture.steward_state).await;

steward_state_account.state.num_pool_validators += 1;
ctx.borrow_mut().set_account(
&fixture.steward_state,
&serialized_steward_state_account(steward_state_account).into(),
);

let (stake_account_address, transient_stake_account_address, withdraw_authority) =
fixture.stake_accounts_for_validator(vote_account).await;

Expand Down Expand Up @@ -1023,6 +1014,17 @@ async fn test_rebalance_increase() {

fixture.submit_transaction_assert_success(tx).await;

let mut steward_state_account: StewardStateAccount =
fixture.load_and_deserialize(&fixture.steward_state).await;

// Force validator into the active set, don't wait for next cycle
steward_state_account.state.num_pool_validators += 1;
steward_state_account.state.validators_added -= 1;
ctx.borrow_mut().set_account(
&fixture.steward_state,
&serialized_steward_state_account(steward_state_account).into(),
);

let reserve_before_rebalance = fixture.get_account(&fixture.stake_pool_meta.reserve).await;

let tx = Transaction::new_signed_with_payer(
Expand Down Expand Up @@ -1231,6 +1233,17 @@ async fn test_rebalance_decrease() {
);
fixture.submit_transaction_assert_success(tx).await;

let mut steward_state_account: StewardStateAccount =
fixture.load_and_deserialize(&fixture.steward_state).await;

// Force validator into the active set, don't wait for next cycle
// steward_state_account.state.num_pool_validators += 1;
steward_state_account.state.validators_added -= 1;
ctx.borrow_mut().set_account(
&fixture.steward_state,
&serialized_steward_state_account(steward_state_account).into(),
);

// Simulating stake deposit
let stake_account_data = fixture.get_account(&stake_account_address).await;

Expand Down Expand Up @@ -1469,6 +1482,17 @@ async fn test_rebalance_other_cases() {
);
fixture.submit_transaction_assert_success(tx).await;

let mut steward_state_account: StewardStateAccount =
fixture.load_and_deserialize(&fixture.steward_state).await;

// Force validator into the active set, don't wait for next cycle
steward_state_account.state.num_pool_validators += 1;
steward_state_account.state.validators_added -= 1;
ctx.borrow_mut().set_account(
&fixture.steward_state,
&serialized_steward_state_account(steward_state_account).into(),
);

let rebalance_ix = Instruction {
program_id: jito_steward::id(),
accounts: jito_steward::accounts::Rebalance {
Expand Down

0 comments on commit 4369738

Please sign in to comment.