Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating testing to lib svm #28

Merged
merged 5 commits into from
Oct 25, 2024
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
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/dex-infinity/src/infinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ impl DexInterface for InfinityDex {
let lst_mint = lst_data.sol_val_calc.lst_mint();
let account_metas = lst_data.sol_val_calc.ix_accounts();
let num_accounts_for_tx = account_metas.len();
let Ok((lst_state, lst_data)) = amm.find_ready_lst(lst_mint) else {
continue;
};

if lst_state.is_input_disabled != 0 {
continue;
}

for pk in lst_data.sol_val_calc.get_accounts_to_update() {
let edges = vec![
Arc::new(InfinityEdgeIdentifier {
Expand Down
11 changes: 4 additions & 7 deletions lib/router-lib/src/test_tools/generate_dex_rpc_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub async fn run_dump_mainnet_data_with_custom_amount(
}
let accounts = rpc_client.get_multiple_accounts(&accounts_needed).await?;

for (_, account) in accounts {
for (_pk, account) in accounts {
// get buffer for upgradable programs
if account.owner == solana_sdk::bpf_loader_upgradeable::ID {
let state = bincode::deserialize::<UpgradeableLoaderState>(&account.data).unwrap();
Expand Down Expand Up @@ -260,7 +260,7 @@ pub async fn run_dump_swap_ix_with_custom_amount(
dump.accounts
.insert(id.input_mint(), account.account.clone());
let account = chain_data_reader
.account(&id.input_mint())
.account(&id.output_mint())
.expect("missing mint");
dump.accounts
.insert(id.output_mint(), account.account.clone());
Expand Down Expand Up @@ -307,9 +307,6 @@ pub async fn run_dump_swap_ix_with_custom_amount(
instruction: bincode::serialize(&swap_exact_out_ix.instruction).unwrap(),
is_exact_out: true,
});

// add exact out accounts
let chain_data_reader = chain_data.read().unwrap();
for account in swap_exact_out_ix.instruction.accounts {
if let Ok(acc) = chain_data_reader.account(&account.pubkey) {
dump.accounts.insert(account.pubkey, acc.account.clone());
Expand Down Expand Up @@ -351,9 +348,9 @@ pub async fn run_dump_swap_ix_with_custom_amount(
debug!("program : {program:?}");
}

for (pk, program) in &dump.accounts {
for (pk, account_data) in &dump.accounts {
let mut hasher = Sha256::new();
hasher.update(program.data());
hasher.update(account_data.data());
let result = hasher.finalize();
let base64 = base64::encode(result);
debug!("account : {pk:?} dump : {base64:?}");
Expand Down
4 changes: 4 additions & 0 deletions programs/simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test-case = "*"
tokio = "1.37.0"
solana-address-lookup-table-program = "1.17"
solana-program-test = "1.17"
solana-program-runtime = "1.17"
solana-sdk = "1.17"
spl-token = { version = "^3.0.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "1.0.0", features = ["no-entrypoint"] }
Expand All @@ -33,6 +34,9 @@ env_logger = "0.9.0"
bincode = "1.3.3"
sha2 = "0.10.8"
base64 = "0.12.3"
litesvm = { git = "https://github.com/blockworks-foundation/litesvm.git", branch = "v0.1.0+solana_1.7" }
tracing = "0.1.37"
tracing-subscriber = "0.3.16"

[profile.test]
inherits = "release"
Loading
Loading