@@ -29,16 +29,25 @@ pub fn map_transaction_error(transport_error: TransportError) -> ProgramError {
29
29
TransportError :: TransactionError ( TransactionError :: InstructionError (
30
30
_,
31
31
instruction_error,
32
- ) ) => ProgramError :: try_from ( instruction_error) . unwrap_or_else ( |ie| match ie {
32
+ ) ) => match instruction_error {
33
+ // In solana-sdk v1.19.0, there is a ProgramError for
34
+ // InstructionError::IncorrectAuthority. This results in the error mapping
35
+ // returning two different values: one for sdk < v1.19 and another for sdk >= v1.19.0.
36
+ // To avoid this situation, handle InstructionError::IncorrectAuthority earlier.
37
+ // Can be removed when Solana v1.19.0 becomes a stable channel (also need to update the
38
+ // test assert for
39
+ // `test_create_program_governance_with_incorrect_upgrade_authority_error`)
33
40
InstructionError :: IncorrectAuthority => {
34
41
ProgramInstructionError :: IncorrectAuthority . into ( )
35
42
}
36
- InstructionError :: PrivilegeEscalation => {
37
- ProgramInstructionError :: PrivilegeEscalation . into ( )
38
- }
39
- _ => panic ! ( "TEST-INSTRUCTION-ERROR {:?}" , ie) ,
40
- } ) ,
41
-
43
+ _ => ProgramError :: try_from ( instruction_error) . unwrap_or_else ( |ie| match ie {
44
+ InstructionError :: IncorrectAuthority => unreachable ! ( ) ,
45
+ InstructionError :: PrivilegeEscalation => {
46
+ ProgramInstructionError :: PrivilegeEscalation . into ( )
47
+ }
48
+ _ => panic ! ( "TEST-INSTRUCTION-ERROR {:?}" , ie) ,
49
+ } ) ,
50
+ } ,
42
51
_ => panic ! ( "TEST-TRANSPORT-ERROR: {:?}" , transport_error) ,
43
52
}
44
53
}
0 commit comments