Skip to content
Merged
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
107 changes: 54 additions & 53 deletions controller/program/tests/tests/admin/add_lst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,21 @@ fn add_lst_jitosol_fixture() {
let ix = add_lst_ix(&keys);
let mut accounts = add_lst_fixtures_accounts_opt(&keys);

accounts.insert(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
);

accounts.insert(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
);
accounts.extend([
(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
),
]);

let (
accounts,
Expand Down Expand Up @@ -213,51 +214,51 @@ fn add_lst_proptest(
let ix = add_lst_ix(&keys);
let mut accounts = add_lst_fixtures_accounts_opt(&keys);

// Common inserts
accounts.insert(
LST_STATE_LIST_ID.into(),
lst_state_list_account(lst_state_list),
);
accounts.insert(POOL_STATE_ID.into(), pool_state_account(pool));
accounts.insert(
Pubkey::new_from_array(admin),
Account {
..Default::default()
},
);
accounts.insert(
Pubkey::new_from_array(payer),
Account {
lamports: u64::MAX,
..Default::default()
},
);
accounts.insert(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
);

let (pool_reserves_addr, _) = find_pool_reserves_ata(&token_program, &mint);
let (protocol_fee_accumulator_addr, _) =
find_protocol_fee_accumulator_ata(&token_program, &mint);

accounts.insert(
pool_reserves_addr,
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, 0)),
);

accounts.insert(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(mint, PROTOCOL_FEE_ID, 0)),
accounts.extend(
[
// Common accounts
(
LST_STATE_LIST_ID.into(),
lst_state_list_account(lst_state_list),
),
(POOL_STATE_ID.into(), pool_state_account(pool)),
(
Pubkey::new_from_array(admin),
Account {
..Default::default()
},
),
(
Pubkey::new_from_array(payer),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
),
(
pool_reserves_addr,
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, 0)),
),
(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(mint, PROTOCOL_FEE_ID, 0)),
),
]
// Additional test-specific accounts
.into_iter()
.chain(additional_accounts),
);

// Additional test-specific inserts
for (pk, acc) in additional_accounts {
accounts.insert(pk, acc);
}

let (
accounts,
InstructionResult {
Expand Down
148 changes: 73 additions & 75 deletions controller/program/tests/tests/admin/remove_lst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,48 +156,45 @@ fn remove_lst_jupsol_fixture() {
let ix = remove_lst_ix(&keys, jupsol_idx as u32);
let mut accounts = remove_lst_fixtures_accounts_opt(&keys);

// Insert the modified LST state list
accounts.insert(
Pubkey::new_from_array(LST_STATE_LIST_ID),
lst_state_list_account(lst_state_list_data),
);

accounts.insert(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
);

accounts.insert(
Pubkey::new_from_array(refund_rent_to),
Account {
..Default::default()
},
);

accounts.insert(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
);

// Add the ATAs with zero balance
let (pool_reserves_addr, _) = find_pool_reserves_ata(token_program, &JUPSOL_MINT.to_bytes());
let (protocol_fee_accumulator_addr, _) =
find_protocol_fee_accumulator_ata(token_program, &JUPSOL_MINT.to_bytes());

accounts.insert(
pool_reserves_addr,
mock_token_acc(raw_token_acc(JUPSOL_MINT.to_bytes(), POOL_STATE_ID, 0)),
);

accounts.insert(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(JUPSOL_MINT.to_bytes(), PROTOCOL_FEE_ID, 0)),
);
// Add the modified LST state list and accounts
accounts.extend([
(
Pubkey::new_from_array(LST_STATE_LIST_ID),
lst_state_list_account(lst_state_list_data),
),
(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(
Pubkey::new_from_array(refund_rent_to),
Account {
..Default::default()
},
),
(
Pubkey::new_from_array(PROTOCOL_FEE_ID),
Account {
..Default::default()
},
),
// Add the ATAs with zero balance
(
pool_reserves_addr,
mock_token_acc(raw_token_acc(JUPSOL_MINT.to_bytes(), POOL_STATE_ID, 0)),
),
(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(JUPSOL_MINT.to_bytes(), PROTOCOL_FEE_ID, 0)),
),
]);

let (
accounts,
Expand Down Expand Up @@ -252,48 +249,49 @@ fn remove_lst_proptest(
let ix = remove_lst_ix(&keys, lst_idx);
let mut accounts = remove_lst_fixtures_accounts_opt(&keys);

// Common inserts
accounts.insert(
LST_STATE_LIST_ID.into(),
lst_state_list_account(lst_state_list),
);
accounts.insert(POOL_STATE_ID.into(), pool_state_account(pool));
accounts.insert(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
);
accounts.insert(
Pubkey::new_from_array(refund_rent_to),
Account {
..Default::default()
},
);
accounts.insert(
Pubkey::new_from_array(mint),
mock_mint(raw_mint(None, None, u64::MAX, 9)),
);
accounts.insert(Pubkey::new_from_array(PROTOCOL_FEE_ID), Account::default());

let (pool_reserves_addr, _) = find_pool_reserves_ata(&TOKENKEG_ID, &mint);
let (protocol_fee_accumulator_addr, _) = find_protocol_fee_accumulator_ata(&TOKENKEG_ID, &mint);

accounts.insert(
pool_reserves_addr,
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, 0)),
);
accounts.insert(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(mint, PROTOCOL_FEE_ID, 0)),
accounts.extend(
[
// Common accounts
(
LST_STATE_LIST_ID.into(),
lst_state_list_account(lst_state_list),
),
(POOL_STATE_ID.into(), pool_state_account(pool)),
(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(
Pubkey::new_from_array(refund_rent_to),
Account {
..Default::default()
},
),
(
Pubkey::new_from_array(mint),
mock_mint(raw_mint(None, None, u64::MAX, 9)),
),
(Pubkey::new_from_array(PROTOCOL_FEE_ID), Account::default()),
(
pool_reserves_addr,
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, 0)),
),
(
protocol_fee_accumulator_addr,
mock_token_acc(raw_token_acc(mint, PROTOCOL_FEE_ID, 0)),
),
]
// Additional test-specific accounts
.into_iter()
.chain(additional_accounts),
);

// Additional test-specific inserts
for (pk, acc) in additional_accounts {
accounts.insert(pk, acc);
}

let (
accounts,
InstructionResult {
Expand Down
57 changes: 30 additions & 27 deletions controller/program/tests/tests/admin/set_sol_value_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ fn set_sol_value_calculator_jupsol_fixture() {
let ix = set_sol_value_calculator_ix(&builder, JUPSOL_FIXTURE_LST_IDX as u32);
let mut accounts = set_sol_value_calculator_fixtures_accounts_opt(&builder);

accounts.insert(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
);

let lsl_pk = Pubkey::new_from_array(LST_STATE_LIST_ID);
let lsl_acc = ALL_FIXTURES.get(&lsl_pk).unwrap().clone();
let mut lsl_data = lsl_acc.data.to_vec();
Expand All @@ -199,7 +191,16 @@ fn set_sol_value_calculator_jupsol_fixture() {
};
lst_mut.sol_value_calculator = Pubkey::new_unique().to_bytes();

accounts.insert(lsl_pk, lst_state_list_account(lsl_data));
accounts.extend([
(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(lsl_pk, lst_state_list_account(lsl_data)),
]);

let (
accounts,
Expand Down Expand Up @@ -259,26 +260,28 @@ fn set_sol_value_calculator_proptest(
let ix = set_sol_value_calculator_ix(&builder, lst_idx as u32);
let mut accounts = set_sol_value_calculator_fixtures_accounts_opt(&builder);

// Common inserts
accounts.insert(LST_STATE_LIST_ID.into(), lst_state_list_account(lsl_data));
accounts.insert(POOL_STATE_ID.into(), pool_state_account(pool));
accounts.insert(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
);
accounts.insert(
Pubkey::new_from_array(*all_pool_reserves.get(&mint).unwrap()),
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, new_balance)),
// Common accounts
accounts.extend(
[
(LST_STATE_LIST_ID.into(), lst_state_list_account(lsl_data)),
(POOL_STATE_ID.into(), pool_state_account(pool)),
(
Pubkey::new_from_array(admin),
Account {
lamports: u64::MAX,
..Default::default()
},
),
(
Pubkey::new_from_array(*all_pool_reserves.get(&mint).unwrap()),
mock_token_acc(raw_token_acc(mint, POOL_STATE_ID, new_balance)),
),
]
// Additional test-specific accounts
.into_iter()
.chain(additional_accounts),
);

// Additional test-specific inserts
for (pk, acc) in additional_accounts {
accounts.insert(pk, acc);
}

let (
accounts,
InstructionResult {
Expand Down
Loading