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 seenTransactionError::InsufficientFundsForFee
- Can’t pay transaction feesTransactionError::AccountNotFound
- Referenced account doesn’t exist
Instruction-level errors occur during instruction execution:
InstructionError::Custom(1)
- System program insufficient funds for transferInstructionError::Custom(3)
- System program invalid data length
Use demand_instruction_error
for instruction-level errors.
§Arguments
expected
- The expected transaction errorresult
- The result of executing a transaction vialitesvm::LiteSVM::send_transaction