Skip to content

Commit

Permalink
fetching get_new_address_tree_proof
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen committed Jun 8, 2024
1 parent 8ec4531 commit 40d961c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 51 deletions.
4 changes: 2 additions & 2 deletions examples/token-escrow/programs/token-escrow/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub async fn perform_escrow_with_event<R: RpcConnection>(
)
.await?
.unwrap();
test_indexer.add_compressed_accounts_with_token_data(&event);
test_indexer.add_compressed_accounts_with_token_data(&event.0);
Ok(())
}

Expand Down Expand Up @@ -449,7 +449,7 @@ pub async fn perform_withdrawal_with_event<R: RpcConnection>(
)
.await?
.unwrap();
test_indexer.add_compressed_accounts_with_token_data(&event);
test_indexer.add_compressed_accounts_with_token_data(&event.0);
Ok(())
}

Expand Down
14 changes: 13 additions & 1 deletion forester/tests/test_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,18 @@ async fn test_photon_interop() {

// Insert value into address queue
info!("Creating address");
env.create_address().await;
let created_addresses = env.create_address().await;


// TODO: once Photon implements the get_multiple_new_address_proofs
// endpoint, adapt the method name and signature, fetch the exclusion proof
// from photon and assert that the proof is the same
let trees = env.get_address_merkle_tree_pubkeys(1).0;
let address_proof = env.indexer
.get_address_tree_proof(trees[0].to_bytes(), created_addresses[0].to_bytes())
.unwrap();

info!("NewAddress proof test-indexer: {:?}", address_proof);


}
47 changes: 1 addition & 46 deletions test-programs/e2e-test/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,4 @@ async fn test_10000_all() {
)
.await;
env.execute_rounds().await;
}


#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_photon_interop() {
spawn_test_validator_with_indexer().await;
let env_accounts = get_test_env_accounts();
let rpc = SolanaRpcConnection::new(None).await;
let mut env = E2ETestEnv::<500, SolanaRpcConnection>::new(
rpc,
&env_accounts,
KeypairActionConfig {
max_output_accounts: Some(3),
..KeypairActionConfig::all_default()
},
GeneralActionConfig {
nullify_compressed_accounts: Some(1.0),
empty_address_queue: Some(1.0),
..GeneralActionConfig::default()
},
0,
// Seed for deterministic randomness, select None for a random seed
Some(1),
"../../circuit-lib/circuitlib-rs/scripts/prover.sh",
)
.await;

let photon_indexer = PhotonIndexer::new(INDEXER_URL.to_string());

// E2ETestEnv is instantiated with one user
let user_index = 0;
// If user has no spl balance it receives an airdrop
env.transfer_sol(user_index).await;
// Nullifies alls tx in queue with probability 1, also empties the queue with probability 1
// (but there is nothing to do)
env.activate_general_actions().await;
// TODO: wait for photon to index
env.transfer_sol(user_index).await;
env.create_address().await;
// TODO: wait for photon to index
// Nullifies tx in queue with probability 1, and empties the queue with probability 1
env.activate_general_actions().await;
// TODO: wait for photon to index
env.create_address().await;

}
}
8 changes: 6 additions & 2 deletions test-utils/src/e2e_test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ where
self.stats.sol_compress += 1;
}

pub async fn create_address(&mut self) {
pub async fn create_address(&mut self) -> Vec<Pubkey> {
println!("\n --------------------------------------------------\n\t\t Create Address\n --------------------------------------------------");
// select number of addresses to create
let num_addresses = self.rng.gen_range(1..=2);
Expand All @@ -720,10 +720,13 @@ where
info!("address_merkle_tree_pubkeys: {:?}", address_merkle_tree_pubkeys);
info!("address_queue_pubkeys: {:?}", address_queue_pubkeys);
let mut address_seeds = Vec::new();
let mut created_addresses = Vec::new();
for _ in 0..num_addresses {
let address_seed: [u8; 32] =
bigint_to_be_bytes_array::<32>(&self.rng.gen_biguint(256)).unwrap();
address_seeds.push(address_seed)
address_seeds.push(address_seed);
// Assuming the address is derived from the seed for simplicity
created_addresses.push(Pubkey::new(&address_seed));
}
let output_compressed_accounts = self.get_merkle_tree_pubkeys(num_addresses);

Expand All @@ -749,6 +752,7 @@ where
.await
.unwrap();
self.stats.create_address += num_addresses;
created_addresses
}

pub async fn transfer_spl(&mut self, user_index: usize) {
Expand Down

0 comments on commit 40d961c

Please sign in to comment.