Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions governance/test-sdk/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,25 @@ pub fn map_transaction_error(transport_error: TransportError) -> ProgramError {
TransportError::TransactionError(TransactionError::InstructionError(
_,
instruction_error,
)) => ProgramError::try_from(instruction_error).unwrap_or_else(|ie| match ie {
)) => match instruction_error {
// In solana-sdk v1.19.0, there is a ProgramError for
// InstructionError::IncorrectAuthority. This results in the error mapping
// returning two different values: one for sdk < v1.19 and another for sdk >= v1.19.0.
// To avoid this situation, handle InstructionError::IncorrectAuthority earlier.
// Can be removed when Solana v1.19.0 becomes a stable channel (also need to update the
// test assert for
// `test_create_program_governance_with_incorrect_upgrade_authority_error`)
InstructionError::IncorrectAuthority => {
ProgramInstructionError::IncorrectAuthority.into()
}
InstructionError::PrivilegeEscalation => {
ProgramInstructionError::PrivilegeEscalation.into()
}
_ => panic!("TEST-INSTRUCTION-ERROR {:?}", ie),
}),

_ => ProgramError::try_from(instruction_error).unwrap_or_else(|ie| match ie {
InstructionError::IncorrectAuthority => unreachable!(),
InstructionError::PrivilegeEscalation => {
ProgramInstructionError::PrivilegeEscalation.into()
}
_ => panic!("TEST-INSTRUCTION-ERROR {:?}", ie),
}),
},
_ => panic!("TEST-TRANSPORT-ERROR: {:?}", transport_error),
}
}
Expand Down