Skip to content

Commit c52f687

Browse files
authored
refactor: use litesvm instead of solana-program-test (#1776)
fix: tests
1 parent 1e2cb93 commit c52f687

File tree

23 files changed

+662
-1536
lines changed

23 files changed

+662
-1536
lines changed

Cargo.lock

Lines changed: 209 additions & 971 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 40 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,54 +57,53 @@ strip = "none"
5757
overflow-checks = true
5858

5959
[workspace.dependencies]
60-
solana-banks-client = { version = "2.2.1" }
61-
solana-banks-interface = { version = "2.2.1" }
62-
solana-program = "2.2.1"
63-
solana-pubkey = "2.2.1"
64-
solana-sdk = "2.2.1"
65-
solana-cpi = "2.2.1"
66-
solana-program-test = { version = "2.2.1" }
67-
solana-client = "2.2.1"
68-
solana-cli-output = "2.2.1"
69-
solana-transaction-status = "2.2.1"
70-
solana-account-decoder = "2.2.1"
71-
solana-account-decoder-client-types = "2.2.1"
72-
solana-transaction-status-client-types = "2.2.1"
73-
solana-rpc = "2.2.1"
74-
solana-rpc-client-api = "2.2.1"
75-
solana-transaction-context = "2.2.1"
76-
solana-frozen-abi = "2.2.1"
77-
solana-frozen-abi-macro = "2.2.1"
78-
solana-msg = { version = "2.2.1" }
79-
solana-zk-token-sdk = "2.2.1"
80-
solana-logger = "2.2.1"
81-
solana-bpf-loader-program = "2.2.1"
82-
solana-bn254 = "2.2.1"
60+
solana-banks-client = { version = "2.2" }
61+
solana-banks-interface = { version = "2.2" }
62+
solana-program = "2.2"
63+
solana-pubkey = "2.2"
64+
solana-sdk = "2.2"
65+
solana-cpi = "2.2"
66+
solana-client = "2.2"
67+
solana-cli-output = "2.2"
68+
solana-transaction-status = "2.2"
69+
solana-account-decoder = "2.2"
70+
solana-account-decoder-client-types = "2.2"
71+
solana-transaction-status-client-types = "2.2"
72+
solana-rpc = "2.2"
73+
solana-rpc-client-api = "2.2"
74+
solana-transaction-context = "2.2"
75+
solana-frozen-abi = "2.2"
76+
solana-frozen-abi-macro = "2.2"
77+
solana-msg = { version = "2.2" }
78+
solana-zk-token-sdk = "2.2"
79+
solana-logger = "2.2"
80+
solana-bpf-loader-program = "2.2"
81+
solana-bn254 = "2.2"
8382
solana-sysvar = { version = "2.1.1" }
8483
solana-program-error = { version = "2.1.1" }
8584
solana-account-info = { version = "2.1.1" }
86-
solana-transaction = { version = "2.2.1" }
87-
solana-transaction-error = { version = "2.2.1" }
88-
solana-hash = { version = "2.2.1" }
89-
solana-clock = { version = "2.2.1" }
90-
solana-signature = { version = "2.2.1" }
91-
solana-commitment-config = { version = "2.2.1" }
92-
solana-account = { version = "2.2.1" }
93-
solana-epoch-info = { version = "2.2.1" }
94-
solana-keypair = { version = "2.2.1" }
95-
solana-compute-budget-interface = { version = "2.2.1" }
96-
solana-signer = { version = "2.2.1" }
97-
solana-instruction = "2.2.1"
98-
solana-rpc-client = "2.2.1"
85+
solana-transaction = { version = "2.2" }
86+
solana-transaction-error = { version = "2.2" }
87+
solana-hash = { version = "2.2" }
88+
solana-clock = { version = "2.2" }
89+
solana-signature = { version = "2.2" }
90+
solana-commitment-config = { version = "2.2" }
91+
solana-account = { version = "2.2" }
92+
solana-epoch-info = { version = "2.2" }
93+
solana-keypair = { version = "2.2" }
94+
solana-compute-budget-interface = { version = "2.2" }
95+
solana-signer = { version = "2.2" }
96+
solana-instruction = "2.2"
97+
solana-rpc-client = "2.2"
98+
solana-compute-budget = { version = "2.2" }
99+
99100
solana-system-interface = { version = "1" }
100101
solana-security-txt = "1.1.1"
101102
spl-token = "7.0.0"
102-
spl-token-2022 = { version = "7", no-default-features = true, features = [
103-
"no-entrypoint",
104-
] }
103+
spl-token-2022 = { version = "7", features = ["no-entrypoint"] }
105104
pinocchio = { version = "0.8.4" }
106105
bs58 = "^0.5.1"
107-
106+
litesvm = "0.6.1"
108107
# Anchor
109108
anchor-lang = { version = "=0.31.1", features = ["idl-build"] }
110109
anchor-spl = "=0.31.1"
@@ -185,7 +184,7 @@ light-poseidon = { version = "0.3.0" }
185184
light-test-utils = { path = "program-tests/utils", version = "1.2.1" }
186185
light-indexed-array = { path = "program-libs/indexed-array", version = "0.1.0" }
187186
create-address-program-test = { path = "program-tests/create-address-test-program", version = "1.0.0" }
188-
groth16-solana = { version = "0.1.0" }
187+
groth16-solana = { version = "0.1.0", git = "https://github.com/lightprotocol/groth16-solana.git", rev = "a18e0f4d3be6c24214fd293e2e7a998b160cda9b" }
189188
bytemuck = { version = "1.19.0" }
190189
arrayvec = "0.7"
191190

@@ -207,12 +206,3 @@ governor = "0.8.0"
207206

208207
# Random
209208
rand = "0.8.5"
210-
211-
212-
[workspace.lints.rust.unexpected_cfgs]
213-
level = "allow"
214-
check-cfg = [
215-
'cfg(target_os, values("solana"))',
216-
'cfg(feature, values("frozen-abi", "no-entrypoint"))',
217-
]
218-
# Arkworks

examples/anchor/name-service/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ solana-sdk = { workspace = true }
3636
light-client = { workspace = true, features = ["devenv"] }
3737
light-test-utils = { workspace = true, features = ["devenv"] }
3838
light-program-test = { workspace = true }
39-
solana-program-test = { workspace = true }
4039
tokio = "1.36.0"

program-tests/account-compression-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ default = ["custom-heap"]
2222
[dev-dependencies]
2323
ark-bn254 = { workspace = true }
2424
ark-ff = { workspace = true }
25-
solana-program-test = { workspace = true }
2625
light-test-utils = { workspace = true, features = ["devenv"] }
2726
light-program-test = { workspace = true, features = ["devenv"] }
2827
light-client = { workspace = true, features = ["devenv", "program-test"] }
@@ -47,3 +46,4 @@ light-bloom-filter = { workspace = true }
4746
light-batched-merkle-tree = { workspace = true }
4847
light-merkle-tree-metadata = { workspace = true }
4948
light-account-checks = { workspace = true }
49+
litesvm = { workspace = true }

program-tests/account-compression-test/tests/address_merkle_tree_tests.rs

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ use light_hasher::{bigint::bigint_to_be_bytes_array, Poseidon};
2020
use light_indexed_merkle_tree::errors::IndexedMerkleTreeError;
2121
use light_merkle_tree_metadata::errors::MerkleTreeMetadataError;
2222
use light_program_test::{
23-
accounts::{
24-
address_tree::create_initialize_address_merkle_tree_and_queue_instruction,
25-
test_accounts::{TestAccounts, NOOP_PROGRAM_ID},
26-
},
27-
indexer::address_tree::AddressMerkleTreeBundle,
28-
program_test::LightProgramTest,
29-
utils::assert::assert_rpc_error,
23+
accounts::address_tree::create_initialize_address_merkle_tree_and_queue_instruction,
24+
indexer::address_tree::AddressMerkleTreeBundle, program_test::LightProgramTest,
25+
utils::assert::assert_rpc_error, ProgramTestConfig,
3026
};
3127
use light_test_utils::{
3228
address::insert_addresses,
@@ -42,7 +38,6 @@ use light_test_utils::{
4238
};
4339
use num_bigint::ToBigUint;
4440
use rand::thread_rng;
45-
use solana_program_test::ProgramTest;
4641
use solana_sdk::{
4742
pubkey::Pubkey,
4843
signature::{Keypair, Signature, Signer},
@@ -226,16 +221,13 @@ async fn initialize_address_merkle_tree_and_queue<R: RpcConnection>(
226221

227222
#[tokio::test]
228223
async fn test_address_queue_and_tree_invalid_sizes() {
229-
let mut program_test = ProgramTest::default();
230-
program_test.add_program("account_compression", ID, None);
231-
program_test.add_program("spl_noop", NOOP_PROGRAM_ID, None);
232-
program_test.set_compute_max_units(1_400_000u64);
233-
let context = program_test.start_with_context().await;
234-
let mut context = LightProgramTest {
235-
context,
236-
test_accounts: TestAccounts::get_local_test_validator_accounts(),
237-
indexer: None,
224+
let config = ProgramTestConfig {
225+
skip_protocol_init: true,
226+
with_prover: false,
227+
..Default::default()
238228
};
229+
let mut context = LightProgramTest::new(config).await.unwrap();
230+
239231
let payer = context.get_payer().insecure_clone();
240232

241233
let address_merkle_tree_keypair = Keypair::new();
@@ -325,17 +317,13 @@ async fn test_address_queue_and_tree_invalid_sizes() {
325317
/// 6. Queue sequence threshold (lower than roots + safety margin).
326318
#[tokio::test]
327319
async fn test_address_queue_and_tree_invalid_config() {
328-
let mut program_test = ProgramTest::default();
329-
program_test.add_program("account_compression", ID, None);
330-
program_test.add_program("spl_noop", NOOP_PROGRAM_ID, None);
331-
program_test.set_compute_max_units(1_400_000u64);
332-
333-
let context = program_test.start_with_context().await;
334-
let mut context = LightProgramTest {
335-
context,
336-
test_accounts: TestAccounts::get_local_test_validator_accounts(),
337-
indexer: None,
320+
let config = ProgramTestConfig {
321+
skip_protocol_init: true,
322+
with_prover: false,
323+
..Default::default()
338324
};
325+
let mut context = LightProgramTest::new(config).await.unwrap();
326+
339327
let payer = context.get_payer().insecure_clone();
340328

341329
let address_merkle_tree_keypair = Keypair::new();
@@ -1423,17 +1411,13 @@ pub async fn test_setup_with_address_merkle_tree(
14231411
Keypair, // payer
14241412
AddressMerkleTreeBundle,
14251413
) {
1426-
let mut program_test = ProgramTest::default();
1427-
program_test.add_program("account_compression", ID, None);
1428-
program_test.add_program("spl_noop", NOOP_PROGRAM_ID, None);
1429-
program_test.set_compute_max_units(1_400_000u64);
1430-
1431-
let context = program_test.start_with_context().await;
1432-
let mut context = LightProgramTest {
1433-
context,
1434-
test_accounts: TestAccounts::get_local_test_validator_accounts(),
1435-
indexer: None,
1414+
let config = ProgramTestConfig {
1415+
skip_protocol_init: true,
1416+
with_prover: false,
1417+
..Default::default()
14361418
};
1419+
let mut context = LightProgramTest::new(config).await.unwrap();
1420+
14371421
let payer = context.get_payer().insecure_clone();
14381422

14391423
let address_merkle_tree_keypair = Keypair::new();

0 commit comments

Comments
 (0)