Skip to content

Commit

Permalink
add test removing all shares
Browse files Browse the repository at this point in the history
  • Loading branch information
wphan committed Oct 27, 2024
1 parent 6647b38 commit e76d6ec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 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,14 @@ 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, 1000 * QUOTE_PRECISION);
assert_eq!(lost_shares, 0);
}

0 comments on commit e76d6ec

Please sign in to comment.