Skip to content
Merged

nits #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ pub const PRICE_ACC_OFFSET_EXPONENT: usize = 89;
pub const PRICE_ACC_OFFSET_PUBLISH_TIME: usize = 93;

/// Maximum age of Pyth price in seconds before we reject it
#[cfg(not(feature = "devnet"))]
pub const MAX_PRICE_AGE: i64 = 60;
#[cfg(feature = "devnet")]
pub const MAX_PRICE_AGE: i64 = 300;

/// ENYwebBThHzmzwPLAQvCucUTsjyfBSZdD9ViXksS4jPu
pub const FEED_ID: [u8; 32] = [
Expand Down
13 changes: 10 additions & 3 deletions src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::instructions::{DepositArgs, InitializeMarketArgs};

pub fn program_id() -> Pubkey {
// deploy and add yours, else will fail due to incorrect authority
Pubkey::from_str_const("e2WFe5epJCxRGFcqeupXyvLkYmLbJcDgWCqrhT4nm9p")
Pubkey::from_str_const("5VSrxdsVhhPRPjitaQuZFVskwS7ZZV3V1fwG2Dy39jSM")
}

pub fn load_svm() -> (TestClient, Keypair) {
Expand Down Expand Up @@ -89,7 +89,6 @@ pub fn setup_market(
)
});

#[cfg(not(feature = "devnet"))]
let ix = Instruction {
program_id: program_id(),
accounts: vec![
Expand All @@ -111,7 +110,15 @@ pub fn setup_market(
};

#[cfg(feature = "devnet")]
let init_cu = 0;
let init_cu = {
if svm.get_account(&config_pda).is_none() {
let msg = Message::new(&[ix], Some(&admin.pubkey()));
let blockhash = svm.latest_blockhash();
svm.send_transaction(Transaction::new(&[&admin], msg, blockhash))
.unwrap();
}
0
};
MarketSetup {
svm,
admin,
Expand Down
14 changes: 14 additions & 0 deletions src/tests/initialize_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ fn test_initialize_market() {

let msg = Message::new(&[ix], Some(&admin.pubkey()));
let blockhash = svm.latest_blockhash();

#[cfg(feature = "devnet")]
if svm.get_account(&config_pda).is_some() {
println!(
"{:<12} | account already exists, skipping init",
"init_market"
);
let account = svm.get_account(&config_pda).expect("Account should exist");
let config = MakerConfig::load(&account.data).unwrap();
assert_eq!(config.market_maker, admin.pubkey().to_bytes());
assert_eq!(config.bump, bump);
return;
}

let tx = svm
.send_transaction(Transaction::new(&[&admin], msg, blockhash))
.unwrap();
Expand Down
Loading