1use solana_sdk::{instruction::InstructionError, transaction};
2
3pub mod address_tree_rollover;
4pub mod assert_address_merkle_tree;
5pub mod assert_compressed_tx;
6pub mod assert_epoch;
7pub mod assert_merkle_tree;
8pub mod assert_queue;
9pub mod assert_rollover;
10pub mod assert_token_tx;
11pub mod e2e_test_env;
12pub mod env_accounts;
13#[allow(unused)]
14pub mod indexer;
15pub mod rpc;
16pub mod spl;
17pub mod state_tree_rollover;
18pub mod system_program;
19pub mod test_env;
20#[allow(unused)]
21pub mod test_forester;
22
23pub use forester_utils::{
24 airdrop_lamports, create_account_instruction,
25 forester_epoch::{Epoch, TreeAccounts, TreeType},
26 get_concurrent_merkle_tree, get_hash_set, get_indexed_merkle_tree,
27 indexer::{AddressMerkleTreeAccounts, AddressMerkleTreeBundle, Indexer, TokenDataWithContext},
28 registry::{
29 create_rollover_address_merkle_tree_instructions,
30 create_rollover_state_merkle_tree_instructions, register_test_forester,
31 update_test_forester,
32 },
33 AccountZeroCopy,
34};
35pub use light_client::{
36 rpc::{
37 assert_rpc_error, solana_rpc::SolanaRpcUrl, RpcConnection, RpcError, SolanaRpcConnection,
38 },
39 transaction_params::{FeeConfig, TransactionParams},
40};
41
42pub fn assert_custom_error_or_program_error(
48 result: Result<solana_sdk::signature::Signature, RpcError>,
49 error_code: u32,
50) -> Result<(), RpcError> {
51 let accepted_errors = [
52 (0, InstructionError::ProgramFailedToComplete),
53 (0, InstructionError::Custom(error_code)),
54 ];
55
56 let is_accepted = accepted_errors.iter().any(|(index, error)| {
57 matches!(result, Err(RpcError::TransactionError(transaction::TransactionError::InstructionError(i, ref e))) if i == (*index as u8) && e == error)
58 });
59
60 if !is_accepted {
61 println!("result {:?}", result);
62 println!("error_code {:?}", error_code);
63 return Err(RpcError::AssertRpcError(format!(
64 "Expected error code {} or program error, got {:?}",
65 error_code, result
66 )));
67 }
68
69 Ok(())
70}