Skip to content

Commit 598c786

Browse files
committed
add test removing all shares
fdas
1 parent 6647b38 commit 598c786

File tree

1 file changed

+9
-0
lines changed
  • programs/drift/src/math/insurance

1 file changed

+9
-0
lines changed

programs/drift/src/math/insurance/tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,13 @@ pub fn if_shares_lost_test() {
165165
< if_stake.last_withdraw_request_value,
166166
true
167167
);
168+
169+
// removing 100% of shares
170+
spot_market.insurance_fund.total_shares = 1000 * QUOTE_PRECISION;
171+
if_stake.update_if_shares(1000 * QUOTE_PRECISION, &spot_market).unwrap();
172+
if_stake.last_withdraw_request_value = (1000 * QUOTE_PRECISION - 1) as u64;
173+
if_stake.last_withdraw_request_shares = 1000 * QUOTE_PRECISION;
174+
let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap();
175+
176+
assert_eq!(lost_shares, 0);
168177
}

0 commit comments

Comments
 (0)