From f179dd2fe2f21815645296d35508cca4e90a4100 Mon Sep 17 00:00:00 2001 From: bergabman Date: Mon, 22 Jul 2024 20:20:50 +0200 Subject: [PATCH] Add default spl programs to custom ledger --- Cargo.toml | 1 + src/context.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 6dc314c..c29fab6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ solana-client = "=1.18.1" solana-ledger = "=1.18.1" solana-runtime = "=1.18.1" solana-account-decoder = "=1.18.1" +solana-program-test = "=1.18.1" spl-token = "4.0.0" serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } diff --git a/src/context.rs b/src/context.rs index eac4d18..77d2982 100644 --- a/src/context.rs +++ b/src/context.rs @@ -509,6 +509,8 @@ impl Valid8Context { let mut accounts: HashMap = HashMap::new(); + + let _ = self.programs .into_iter() .map(|pa|{ @@ -528,6 +530,10 @@ impl Valid8Context { AccountSharedData::new(faucet_lamports, 0, &system_program::id()) ); + for (address, account) in solana_program_test::programs::spl_programs(&Rent::default()) { + accounts.entry(address).or_insert(account); + } + let mut genesis_config = create_genesis_config_with_leader_ex( mint_lamports, &mint_address.pubkey(),