#[macro_export] macro_rules! assert_instruction_error { ( $error:expr, $matcher:pat ) => { match $error { solana_program_test::BanksClientError::TransactionError( solana_sdk::transaction::TransactionError::InstructionError(_, $matcher), ) => { assert!(true) } err => assert!(false, "Expected instruction error but got '{:#?}'", err), }; }; } #[macro_export] macro_rules! assert_custom_error { ( $error:expr, $matcher:pat ) => { match $error { solana_program_test::BanksClientError::TransactionError( solana_sdk::transaction::TransactionError::InstructionError( _, solana_sdk::instruction::InstructionError::Custom(x), ), ) => match num_traits::FromPrimitive::from_i32(x as i32) { Some($matcher) => assert!(true), Some(other) => { assert!( false, "Expected another custom instruction error than '{:#?}'", other ) } None => assert!(false, "Expected custom instruction error"), }, err => assert!( false, "Expected custom instruction error but got '{:#?}'", err ), }; }; }