Skip to content

Commit 0e0fec6

Browse files
authored
chore: add unit tests and cleanups (#913)
Changes: - add signer checks unit tests - add cpi context unit tests - add cpi context associated Merkle tree check - moved hash output compressed accounts and prepare append cpi instruction data into function - removed dead code in hash input compressed accounts - removed registered program pda type from anchor Instruction structs other than in account compression program
1 parent aa03d83 commit 0e0fec6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1184
-344
lines changed

cli/accounts/cpi_context_Bvux5m7rMGXJfjNCKUXHaRMcVJCiDe6iWu8ANj8kpwu5.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

examples/token-escrow/programs/token-escrow/src/escrow_with_compressed_pda/escrow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ pub fn process_escrow_compressed_tokens_with_compressed_pda<'info>(
9595
proof.clone(),
9696
cpi_context,
9797
)?;
98-
msg!("escrow compressed tokens with compressed pda");
9998
cpi_compressed_pda_transfer(
10099
ctx,
101100
proof,

programs/account-compression/src/config_accounts/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

programs/account-compression/src/instructions/append_leaves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl GroupAccess for StateMerkleTreeAccount {
3030
&self.metadata.access_metadata.owner
3131
}
3232

33-
fn get_delegate(&self) -> &Pubkey {
33+
fn get_program_owner(&self) -> &Pubkey {
3434
&self.metadata.access_metadata.program_owner
3535
}
3636
}

programs/account-compression/src/instructions/initialize_address_merkle_tree_and_queue.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ pub fn process_initialize_address_merkle_tree_and_queue<'info>(
5959
merkle_tree_config: AddressMerkleTreeConfig,
6060
queue_config: AddressQueueConfig,
6161
) -> Result<()> {
62-
if merkle_tree_config.close_threshold.is_some() {
63-
unimplemented!("Close threshold not supported.");
64-
}
65-
6662
let merkle_tree_rent = ctx.accounts.merkle_tree.get_lamports();
6763
process_initialize_address_queue(
6864
&ctx.accounts.queue.to_account_info(),

programs/account-compression/src/instructions/initialize_group_authority.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anchor_lang::{prelude::*, solana_program::pubkey::Pubkey};
22

3-
use crate::{config_accounts::GroupAuthority, utils::constants::GROUP_AUTHORITY_SEED};
3+
use crate::{state::GroupAuthority, utils::constants::GROUP_AUTHORITY_SEED};
44

55
#[derive(Accounts)]
66
pub struct InitializeGroupAuthority<'info> {

programs/account-compression/src/instructions/initialize_state_merkle_tree_and_nullifier_queue.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ pub fn process_initialize_state_merkle_tree_and_nullifier_queue(
7575
nullifier_queue_config: NullifierQueueConfig,
7676
additional_rent: u64,
7777
) -> Result<()> {
78-
if state_merkle_tree_config.close_threshold.is_some() {
79-
unimplemented!("Close threshold not supported.");
80-
}
81-
8278
process_initialize_state_merkle_tree(
8379
&ctx.accounts.merkle_tree,
8480
index,

programs/account-compression/src/instructions/insert_into_queues.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ pub struct InsertIntoQueues<'info> {
2727
/// Inserts every element into the indexed array.
2828
/// Throws an error if the element already exists.
2929
/// Expects an indexed queue account as for every index as remaining account.
30-
pub fn process_insert_into_queues<
31-
'a,
32-
'b,
33-
'c: 'info,
34-
'info,
35-
MerkleTreeAccount: Owner + ZeroCopy, // SequenceNumber,
36-
>(
30+
pub fn process_insert_into_queues<'a, 'b, 'c: 'info, 'info, MerkleTreeAccount: Owner + ZeroCopy>(
3731
ctx: Context<'a, 'b, 'c, 'info, InsertIntoQueues<'info>>,
3832
elements: &'a [[u8; 32]],
3933
queue_type: QueueType,

programs/account-compression/src/instructions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub use update_group_authority::*;
2525
pub mod register_program;
2626
pub use register_program::*;
2727

28-
pub mod rollover_state_merkle_tree;
29-
pub use rollover_state_merkle_tree::*;
28+
pub mod rollover_state_merkle_tree_and_queue;
29+
pub use rollover_state_merkle_tree_and_queue::*;
3030

3131
pub mod rollover_address_merkle_tree_and_queue;
3232
pub use rollover_address_merkle_tree_and_queue::*;

0 commit comments

Comments
 (0)