Skip to content

Commit

Permalink
program: fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
farnyser committed May 30, 2024
1 parent a401798 commit 1a1f6fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions programs/mango-v4/tests/cases/test_collateral_fees.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![allow(unused_assignments)]

use super::*;
use anchor_spl::token::accessor::mint;
use std::collections::HashMap;

#[tokio::test]
async fn test_collateral_fees() -> Result<(), TransportError> {
Expand All @@ -10,11 +13,17 @@ async fn test_collateral_fees() -> Result<(), TransportError> {
let owner = context.users[0].key;
let payer = context.users[1].key;
let mints = &context.mints[0..2];
let mut prices = HashMap::new();

// 1 unit = 1$
prices.insert(mints[0].pubkey, 1_000_000f64);
prices.insert(mints[1].pubkey, 1_000_000f64);

let mango_setup::GroupWithTokens { group, tokens, .. } = mango_setup::GroupWithTokensConfig {
admin,
payer,
mints: mints.to_vec(),
prices: prices,
..mango_setup::GroupWithTokensConfig::default()
}
.create(solana)
Expand Down
5 changes: 4 additions & 1 deletion programs/mango-v4/tests/program_test/mango_setup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(dead_code)]

use anchor_lang::prelude::*;
use std::collections::HashMap;

use super::mango_client::*;
use super::solana::SolanaCookie;
Expand All @@ -11,6 +12,7 @@ pub struct GroupWithTokensConfig {
pub admin: TestKeypair,
pub payer: TestKeypair,
pub mints: Vec<MintCookie>,
pub prices: HashMap<Pubkey, f64>,
pub zero_token_is_quote: bool,
}

Expand Down Expand Up @@ -38,6 +40,7 @@ impl<'a> GroupWithTokensConfig {
admin,
payer,
mints,
prices,
zero_token_is_quote,
} = self;
let create_group_accounts = send_tx(
Expand Down Expand Up @@ -74,7 +77,7 @@ impl<'a> GroupWithTokensConfig {
group,
admin,
mint: mint.pubkey,
price: 1.0,
price: prices.get(&mint.pubkey).copied().unwrap_or(1.0f64),
oracle,
},
)
Expand Down

0 comments on commit 1a1f6fa

Please sign in to comment.