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
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion program-tests/utils/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use light_sdk::{self as sdk};
// prove_by_index: sdk_merkle_context.prove_by_index,
// }
// }

// pub fn program_to_sdk_merkle_context(
// program_merkle_context: ProgramMerkleContext,
// ) -> sdk::merkle_context::MerkleContext {
Expand Down
3 changes: 2 additions & 1 deletion sdk-libs/client/src/indexer/photon_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::{
CompressedAccount, CompressedTokenAccount, OwnerBalance, QueueElementsResult,
SignatureWithMetadata, TokenBalance,
},
BatchAddressUpdateIndexerResponse, MerkleProofWithContext,
BatchAddressUpdateIndexerResponse,
};
use crate::indexer::{
base58::Base58Conversions,
Expand Down Expand Up @@ -1590,6 +1590,7 @@ impl Indexer for PhotonIndexer {
unimplemented!("get_queue_elements");
#[cfg(feature = "v2")]
{
use super::MerkleProofWithContext;
let pubkey = _pubkey;
let queue_type = _queue_type;
let limit = _num_elements;
Expand Down
13 changes: 7 additions & 6 deletions sdk-libs/program-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[features]
default = []
devenv = ["v2", "light-client/devenv", "light-prover-client/devenv"]
devenv = ["v2", "light-client/devenv", "light-prover-client/devenv", "dep:account-compression", "dep:light-compressed-token", "dep:light-registry", "dep:light-batched-merkle-tree", "dep:light-concurrent-merkle-tree"]
v2 = ["light-client/v2"]

[dependencies]
Expand All @@ -16,19 +16,19 @@ light-indexed-merkle-tree = { workspace = true, features = ["solana"] }
light-indexed-array = { workspace = true }
light-merkle-tree-reference = { workspace = true }
light-merkle-tree-metadata = { workspace = true, features = ["anchor"] }
light-concurrent-merkle-tree = { workspace = true }
light-concurrent-merkle-tree = { workspace = true, optional = true }
light-hasher = { workspace = true }
light-compressed-account = { workspace = true, features = ["anchor"] }
light-batched-merkle-tree = { workspace = true, features = ["test-only"] }
light-batched-merkle-tree = { workspace = true, features = ["test-only"], optional = true }

# unreleased
light-client = { workspace = true, features = ["program-test"] }
light-prover-client = { workspace = true }
litesvm = { workspace = true }

light-registry = { workspace = true, features = ["cpi"] }
light-compressed-token = { workspace = true, features = ["cpi"] }
account-compression = { workspace = true, features = ["cpi"] }
light-registry = { workspace = true, features = ["cpi"], optional = true }
light-compressed-token = { workspace = true, features = ["cpi"], optional = true }
account-compression = { workspace = true, features = ["cpi"], optional = true }
photon-api = { workspace = true }

log = { workspace = true }
Expand Down Expand Up @@ -58,3 +58,4 @@ bs58 = { workspace = true }
light-sdk-types = { workspace = true }
tabled = { workspace = true }
chrono = "0.4"
base64 = "0.22"
12 changes: 7 additions & 5 deletions sdk-libs/program-test/src/accounts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#[cfg(feature = "v2")]
#[cfg(feature = "devenv")]
pub mod address_tree;
#[cfg(feature = "devenv")]
pub mod address_tree_v2;
#[cfg(feature = "devenv")]
pub mod initialize;
#[cfg(feature = "devenv")]
pub mod register_program;
pub mod registered_program_accounts;
#[cfg(feature = "v2")]
pub mod state_tree_v2;

pub mod address_tree;
#[cfg(feature = "devenv")]
pub mod state_tree;
#[cfg(feature = "devenv")]
pub mod state_tree_v2;
pub mod test_accounts;
pub mod test_keypairs;
89 changes: 66 additions & 23 deletions sdk-libs/program-test/src/accounts/test_accounts.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use light_client::indexer::{AddressMerkleTreeAccounts, StateMerkleTreeAccounts, TreeInfo};
use light_compressed_account::TreeType;
#[cfg(feature = "devenv")]
use light_registry::{
account_compression_cpi::sdk::get_registered_program_pda,
sdk::create_register_program_instruction,
utils::{get_forester_pda, get_protocol_config_pda_address},
};
use solana_sdk::{
pubkey,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
#[cfg(feature = "devenv")]
use solana_sdk::signature::Signer;
use solana_sdk::{pubkey, pubkey::Pubkey, signature::Keypair};

use super::{initialize::*, test_keypairs::*};
#[cfg(feature = "devenv")]
use super::initialize::*;
use super::test_keypairs::*;

pub const NOOP_PROGRAM_ID: Pubkey = pubkey!("noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV");

Expand Down Expand Up @@ -62,10 +63,10 @@ impl TestAccounts {
governance_authority_pda: Pubkey::default(),
group_pda: Pubkey::default(),
forester: Keypair::from_bytes(&FORESTER_TEST_KEYPAIR).unwrap(),
registered_program_pda: get_registered_program_pda(&Pubkey::from(
light_sdk::constants::LIGHT_SYSTEM_PROGRAM_ID,
)),
registered_registry_program_pda: get_registered_program_pda(&light_registry::ID),
registered_program_pda: pubkey!("35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh"),
registered_registry_program_pda: pubkey!(
"DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w"
),
registered_forester_pda: Pubkey::default(),
},
v1_state_trees: vec![
Expand Down Expand Up @@ -120,31 +121,73 @@ impl TestAccounts {
}

pub fn get_program_test_test_accounts() -> TestAccounts {
let group_seed_keypair = Keypair::from_bytes(&GROUP_PDA_SEED_TEST_KEYPAIR).unwrap();
let group_pda = get_group_pda(group_seed_keypair.pubkey());

let payer = Keypair::from_bytes(&PAYER_KEYPAIR).unwrap();
let protocol_config_pda = get_protocol_config_pda_address();
let (_, registered_program_pda) = create_register_program_instruction(
payer.pubkey(),
#[cfg(feature = "devenv")]
let (
group_pda,
protocol_config_pda,
registered_program_pda,
registered_registry_program_pda,
registered_forester_pda,
) = {
let group_seed_keypair = Keypair::from_bytes(&GROUP_PDA_SEED_TEST_KEYPAIR).unwrap();
let group_pda = get_group_pda(group_seed_keypair.pubkey());
let payer = Keypair::from_bytes(&PAYER_KEYPAIR).unwrap();
let protocol_config_pda = get_protocol_config_pda_address();
let (_, registered_program_pda) = create_register_program_instruction(
payer.pubkey(),
protocol_config_pda,
group_pda,
Pubkey::from(light_sdk::constants::LIGHT_SYSTEM_PROGRAM_ID),
);
let registered_registry_program_pda =
get_registered_program_pda(&pubkey!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX"));
let forester = Keypair::from_bytes(&FORESTER_TEST_KEYPAIR).unwrap();
let registered_forester_pda = get_forester_pda(&forester.pubkey()).0;
(
group_pda,
protocol_config_pda.0,
registered_program_pda,
registered_registry_program_pda,
registered_forester_pda,
)
};

#[cfg(not(feature = "devenv"))]
let (
group_pda,
Pubkey::from(light_sdk::constants::LIGHT_SYSTEM_PROGRAM_ID),
);
protocol_config_pda,
registered_program_pda,
registered_registry_program_pda,
registered_forester_pda,
) = {
// Hardcoded PDAs for non-devenv mode (these match the devenv calculations)
let group_pda = pubkey!("Fomh1YizJdDfqvMJhC42cLNdcJM8NMM2NfxgZVEh3rkC");
let protocol_config_pda = pubkey!("CuEtcKkkbTn6qy2qxqDswq5U2ADsqoipYDAYfRvxPjcp");
let registered_program_pda = pubkey!("35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh");
let registered_registry_program_pda =
pubkey!("DumMsyvkaGJG4QnQ1BhTgvoRMXsgGxfpKDUCr22Xqu4w");
let registered_forester_pda = pubkey!("3FBt1BPQHCQkS8k3wrUXMfB6JBhtMhEqQXueHRw2ojZV");
(
group_pda,
protocol_config_pda,
registered_program_pda,
registered_registry_program_pda,
registered_forester_pda,
)
};

let registered_registry_program_pda = get_registered_program_pda(&light_registry::ID);
let payer = Keypair::from_bytes(&PAYER_KEYPAIR).unwrap();
let forester = Keypair::from_bytes(&FORESTER_TEST_KEYPAIR).unwrap();

let forester_pubkey = forester.pubkey();
TestAccounts {
protocol: ProtocolAccounts {
governance_authority: payer,
governance_authority_pda: protocol_config_pda.0,
governance_authority_pda: protocol_config_pda,
group_pda,
forester,
registered_program_pda,
registered_registry_program_pda,
registered_forester_pda: get_forester_pda(&forester_pubkey).0,
registered_forester_pda,
},
v1_state_trees: vec![
StateMerkleTreeAccounts {
Expand Down
6 changes: 5 additions & 1 deletion sdk-libs/program-test/src/indexer/address_tree.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::fmt::Debug;

#[cfg(feature = "devenv")]
use light_batched_merkle_tree::constants::DEFAULT_BATCH_ROOT_HISTORY_LEN;
use light_client::{
fee::FeeConfig,
indexer::{AddressMerkleTreeAccounts, IndexerError},
};
use light_concurrent_merkle_tree::light_hasher::Poseidon;
use light_hasher::Poseidon;
use light_indexed_merkle_tree::{
array::{IndexedArray, IndexedElement, IndexedElementBundle},
reference::IndexedMerkleTree,
Expand All @@ -15,6 +16,9 @@ use light_sdk::constants::STATE_MERKLE_TREE_ROOTS;
use num_bigint::{BigInt, BigUint};
use num_traits::ops::bytes::FromBytes;

#[cfg(not(feature = "devenv"))]
use super::test_indexer::DEFAULT_BATCH_ROOT_HISTORY_LEN;

#[derive(Debug, Clone)]
pub enum IndexedMerkleTreeVersion {
V1(Box<IndexedMerkleTree<Poseidon, usize>>),
Expand Down
1 change: 1 addition & 0 deletions sdk-libs/program-test/src/indexer/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub trait TestIndexerExtensions {

fn get_proof_by_index(&mut self, merkle_tree_pubkey: Pubkey, index: u64) -> MerkleProof;

#[cfg(feature = "devenv")]
async fn finalize_batched_address_tree_update(
&mut self,
merkle_tree_pubkey: Pubkey,
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/program-test/src/indexer/state_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Debug;

use light_client::indexer::{IndexerError, StateMerkleTreeAccounts};
use light_compressed_account::TreeType;
use light_concurrent_merkle_tree::light_hasher::Poseidon;
use light_hasher::Poseidon;
use light_merkle_tree_reference::MerkleTree;

#[derive(Debug, Clone)]
Expand Down
Loading
Loading