Function demand_transaction_error

Source
pub fn demand_transaction_error(
    expected: TransactionError,
    result: TransactionResult,
)
Expand description

Asserts that a transaction error matches the expected error.

This function tests for transaction-level errors that occur before instruction execution, such as AlreadyProcessed, InsufficientFundsForFee, AccountNotFound, etc.

§Important Distinction

Transaction-level errors occur during transaction validation/processing:

  • TransactionError::AlreadyProcessed - Transaction already seen
  • TransactionError::InsufficientFundsForFee - Can’t pay transaction fees
  • TransactionError::AccountNotFound - Referenced account doesn’t exist

Instruction-level errors occur during instruction execution:

  • InstructionError::Custom(1) - System program insufficient funds for transfer
  • InstructionError::Custom(3) - System program invalid data length

Use demand_instruction_error for instruction-level errors.

§Arguments