Skip to content

Commit

Permalink
refactor: optional stake_history arg is never None (#34556)
Browse files Browse the repository at this point in the history
refactor: optional stake_history arg is never none
  • Loading branch information
jstarry authored Dec 22, 2023
1 parent 8a8466c commit 88af74d
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 147 deletions.
2 changes: 1 addition & 1 deletion cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,7 @@ pub fn build_stake_state(
deactivating,
} = stake.delegation.stake_activating_and_deactivating(
current_epoch,
Some(stake_history),
stake_history,
new_rate_activation_epoch,
);
let lockup = if lockup.is_in_force(clock, None) {
Expand Down
4 changes: 2 additions & 2 deletions program-test/tests/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async fn stake_rewards_from_warp() {
assert_eq!(
stake
.delegation
.stake_activating_and_deactivating(clock.epoch, Some(&stake_history), None),
.stake_activating_and_deactivating(clock.epoch, &stake_history, None),
StakeActivationStatus::with_effective(stake.delegation.stake),
);
}
Expand Down Expand Up @@ -321,7 +321,7 @@ async fn stake_rewards_filter_bench_core(num_stake_accounts: u64) {
assert_eq!(
stake
.delegation
.stake_activating_and_deactivating(clock.epoch, Some(&stake_history), None),
.stake_activating_and_deactivating(clock.epoch, &stake_history, None),
StakeActivationStatus::with_effective(stake.delegation.stake),
);
}
Expand Down
28 changes: 8 additions & 20 deletions programs/stake/src/stake_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ mod tests {
if let StakeStateV2::Stake(_meta, stake, _stake_flags) = account.state().unwrap() {
let stake_status = stake.delegation.stake_activating_and_deactivating(
clock.epoch,
Some(stake_history),
stake_history,
None,
);
active_stake += stake_status.effective;
Expand Down Expand Up @@ -6846,15 +6846,11 @@ mod tests {
create_account_shared_data_for_test(&stake_history),
);
if stake_amount
== stake.stake(
clock.epoch,
Some(&stake_history),
new_warmup_cooldown_rate_epoch,
)
== stake.stake(clock.epoch, &stake_history, new_warmup_cooldown_rate_epoch)
&& merge_from_amount
== merge_from_stake.stake(
clock.epoch,
Some(&stake_history),
&stake_history,
new_warmup_cooldown_rate_epoch,
)
{
Expand Down Expand Up @@ -6935,14 +6931,10 @@ mod tests {
stake_history::id(),
create_account_shared_data_for_test(&stake_history),
);
if 0 == stake.stake(
clock.epoch,
Some(&stake_history),
new_warmup_cooldown_rate_epoch,
) && 0
== merge_from_stake.stake(
if 0 == stake.stake(clock.epoch, &stake_history, new_warmup_cooldown_rate_epoch)
&& 0 == merge_from_stake.stake(
clock.epoch,
Some(&stake_history),
&stake_history,
new_warmup_cooldown_rate_epoch,
)
{
Expand Down Expand Up @@ -7388,11 +7380,7 @@ mod tests {
initial_stake_state
.delegation()
.unwrap()
.stake_activating_and_deactivating(
current_epoch,
Some(&stake_history),
None
)
.stake_activating_and_deactivating(current_epoch, &stake_history, None)
);
}

Expand Down Expand Up @@ -7888,7 +7876,7 @@ mod tests {
},
stake.delegation.stake_activating_and_deactivating(
current_epoch,
Some(&stake_history),
&stake_history,
None
)
);
Expand Down
Loading

0 comments on commit 88af74d

Please sign in to comment.