forked from solana-labs/solana-program-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dupe lite refresh (solana-labs#62) (solana-labs#63)
* lite refresh that doesn't take the oracle price when depositing * mark reserve as stale * format * added fask track for repay and made a test * check that reserve is stale after depositing * clean up Co-authored-by: ra <RealAwesomeness@users.noreply.github.com> Co-authored-by: ra <RealAwesomeness@users.noreply.github.com>
- Loading branch information
1 parent
87f6ca2
commit 920a449
Showing
3 changed files
with
108 additions
and
21 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
71 changes: 71 additions & 0 deletions
71
token-lending/program/tests/deposit_reserve_liquidity_and_obligation_collateral.rs
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,71 @@ | ||
#![cfg(feature = "test-bpf")] | ||
|
||
mod helpers; | ||
|
||
use helpers::*; | ||
use solana_program_test::*; | ||
use solana_sdk::{pubkey::Pubkey, signature::Keypair}; | ||
use spl_token_lending::processor::process_instruction; | ||
|
||
#[tokio::test] | ||
async fn test_success() { | ||
let mut test = ProgramTest::new( | ||
"spl_token_lending", | ||
spl_token_lending::id(), | ||
processor!(process_instruction), | ||
); | ||
|
||
// limit to track compute unit increase | ||
test.set_bpf_compute_max_units(70_000); | ||
|
||
let user_accounts_owner = Keypair::new(); | ||
let lending_market = add_lending_market(&mut test); | ||
|
||
let usdc_mint = add_usdc_mint(&mut test); | ||
let usdc_oracle = add_usdc_oracle(&mut test); | ||
let usdc_test_reserve = add_reserve( | ||
&mut test, | ||
&lending_market, | ||
&usdc_oracle, | ||
&user_accounts_owner, | ||
AddReserveArgs { | ||
user_liquidity_amount: 100 * FRACTIONAL_TO_USDC, | ||
liquidity_amount: 10_000 * FRACTIONAL_TO_USDC, | ||
liquidity_mint_decimals: usdc_mint.decimals, | ||
liquidity_mint_pubkey: usdc_mint.pubkey, | ||
config: test_reserve_config(), | ||
mark_fresh: true, | ||
..AddReserveArgs::default() | ||
}, | ||
); | ||
|
||
let test_obligation = add_obligation( | ||
&mut test, | ||
&lending_market, | ||
&user_accounts_owner, | ||
AddObligationArgs::default(), | ||
); | ||
|
||
let (mut banks_client, payer, _recent_blockhash) = test.start().await; | ||
|
||
test_obligation.validate_state(&mut banks_client).await; | ||
|
||
// let initial_collateral_supply_balance = | ||
// get_token_balance(&mut banks_client, usdc_test_reserve.collateral_supply_pubkey).await; | ||
// let initial_user_collateral_balance = | ||
// get_token_balance(&mut banks_client, usdc_test_reserve.user_collateral_pubkey).await; | ||
|
||
lending_market | ||
.deposit_obligation_and_collateral( | ||
&mut banks_client, | ||
&user_accounts_owner, | ||
&payer, | ||
&usdc_test_reserve, | ||
&test_obligation, | ||
100 * FRACTIONAL_TO_USDC, | ||
) | ||
.await; | ||
|
||
let usdc_reserve = usdc_test_reserve.get_state(&mut banks_client).await; | ||
assert_eq!(usdc_reserve.last_update.stale, true); | ||
} |
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