50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
|
#![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;
|
||
|
|
||
|
const FRACTIONAL_TO_USDC: u64 = 1_000_000;
|
||
|
|
||
|
#[tokio::test]
|
||
|
async fn test_success() {
|
||
|
let mut test = ProgramTest::new(
|
||
|
"spl_token_lending",
|
||
|
spl_token_lending::id(),
|
||
|
processor!(process_instruction),
|
||
|
);
|
||
|
|
||
|
let user_accounts_owner = Keypair::new();
|
||
|
let usdc_mint = add_usdc_mint(&mut test);
|
||
|
let lending_market = add_lending_market(&mut test, usdc_mint.pubkey);
|
||
|
|
||
|
let usdc_reserve = add_reserve(
|
||
|
&mut test,
|
||
|
&user_accounts_owner,
|
||
|
&lending_market,
|
||
|
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,
|
||
|
..AddReserveArgs::default()
|
||
|
},
|
||
|
);
|
||
|
|
||
|
let (mut banks_client, payer, _recent_blockhash) = test.start().await;
|
||
|
|
||
|
lending_market
|
||
|
.deposit(
|
||
|
&mut banks_client,
|
||
|
&user_accounts_owner,
|
||
|
&payer,
|
||
|
&usdc_reserve,
|
||
|
100 * FRACTIONAL_TO_USDC,
|
||
|
)
|
||
|
.await;
|
||
|
}
|