Skip to content

Commit

Permalink
add test removing all shares
Browse files Browse the repository at this point in the history
fdas
  • Loading branch information
wphan committed Oct 27, 2024
1 parent 6647b38 commit 598c786
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions programs/drift/src/math/insurance/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,13 @@ pub fn if_shares_lost_test() {
< if_stake.last_withdraw_request_value,
true
);

// removing 100% of shares
spot_market.insurance_fund.total_shares = 1000 * QUOTE_PRECISION;
if_stake.update_if_shares(1000 * QUOTE_PRECISION, &spot_market).unwrap();
if_stake.last_withdraw_request_value = (1000 * QUOTE_PRECISION - 1) as u64;
if_stake.last_withdraw_request_shares = 1000 * QUOTE_PRECISION;
let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap();

assert_eq!(lost_shares, 0);
}

0 comments on commit 598c786

Please sign in to comment.