-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
program: add test for get_token_amount for bonk
- Loading branch information
1 parent
3170473
commit 446ecf6
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#[cfg(test)] | ||
mod test { | ||
use crate::math::spot_balance::{get_spot_balance, get_token_amount}; | ||
use crate::state::spot_market::{SpotBalanceType, SpotMarket}; | ||
use crate::SPOT_CUMULATIVE_INTEREST_PRECISION; | ||
|
||
#[test] | ||
fn bonk() { | ||
let spot_market = SpotMarket { | ||
cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, | ||
decimals: 5, | ||
..SpotMarket::default_quote_market() | ||
}; | ||
|
||
let one_bonk = 10_u128.pow(spot_market.decimals); | ||
|
||
let balance = get_spot_balance(one_bonk, &spot_market, &SpotBalanceType::Deposit, false).unwrap(); | ||
|
||
let token_amount = get_token_amount(balance, &spot_market, &SpotBalanceType::Deposit).unwrap(); | ||
assert_eq!(token_amount, one_bonk); | ||
} | ||
} |