From e76d6ec2661b44b56fe24eeb19f90e8edc0771ef Mon Sep 17 00:00:00 2001 From: wphan Date: Sun, 27 Oct 2024 13:11:42 -0700 Subject: [PATCH] add test removing all shares --- programs/drift/src/math/insurance/tests.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/programs/drift/src/math/insurance/tests.rs b/programs/drift/src/math/insurance/tests.rs index 46287cedb..b0e28f8d5 100644 --- a/programs/drift/src/math/insurance/tests.rs +++ b/programs/drift/src/math/insurance/tests.rs @@ -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); }