|
1 | 1 | mod setup; |
2 | 2 |
|
3 | | -use std::mem::size_of; |
4 | | - |
| 3 | +use assert_matches::assert_matches; |
5 | 4 | use setup::{mint, TOKEN_PROGRAM_ID}; |
6 | | -use solana_program_test::{tokio, ProgramTest}; |
| 5 | +use solana_program_test::{tokio, BanksClientError, ProgramTest}; |
7 | 6 | use solana_sdk::{ |
8 | 7 | instruction::InstructionError, |
9 | 8 | pubkey::Pubkey, |
10 | 9 | signature::{Keypair, Signer}, |
11 | 10 | system_instruction, |
12 | | - transaction::Transaction, |
| 11 | + transaction::{Transaction, TransactionError}, |
13 | 12 | }; |
14 | 13 | use spl_token_interface::state::{account::Account, mint::Mint, multisig::Multisig}; |
| 14 | +use std::mem::size_of; |
15 | 15 |
|
16 | 16 | #[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")] |
17 | 17 | #[tokio::test] |
@@ -417,7 +417,13 @@ async fn fail_withdraw_excess_lamports_from_mint_wrong_authority(token_program: |
417 | 417 |
|
418 | 418 | // The we expect an error. |
419 | 419 |
|
420 | | - assert_custom_error!(error, spl_token::error::TokenError::OwnerMismatch); |
| 420 | + assert_matches!( |
| 421 | + error, |
| 422 | + BanksClientError::TransactionError(TransactionError::InstructionError( |
| 423 | + _, |
| 424 | + InstructionError::Custom(4) // TokenError::OwnerMismatch |
| 425 | + )) |
| 426 | + ); |
421 | 427 | } |
422 | 428 |
|
423 | 429 | #[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")] |
@@ -527,7 +533,13 @@ async fn fail_withdraw_excess_lamports_from_account_wrong_authority(token_progra |
527 | 533 |
|
528 | 534 | // The we expect an error. |
529 | 535 |
|
530 | | - assert_custom_error!(error, spl_token::error::TokenError::OwnerMismatch); |
| 536 | + assert_matches!( |
| 537 | + error, |
| 538 | + BanksClientError::TransactionError(TransactionError::InstructionError( |
| 539 | + _, |
| 540 | + InstructionError::Custom(4) // TokenError::OwnerMismatch |
| 541 | + )) |
| 542 | + ); |
531 | 543 | } |
532 | 544 |
|
533 | 545 | #[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")] |
@@ -628,7 +640,13 @@ async fn fail_withdraw_excess_lamports_from_multisig_wrong_authority(token_progr |
628 | 640 |
|
629 | 641 | // The we expect an error. |
630 | 642 |
|
631 | | - assert_custom_error!(error, spl_token::error::TokenError::OwnerMismatch); |
| 643 | + assert_matches!( |
| 644 | + error, |
| 645 | + BanksClientError::TransactionError(TransactionError::InstructionError( |
| 646 | + _, |
| 647 | + InstructionError::Custom(4) // TokenError::OwnerMismatch |
| 648 | + )) |
| 649 | + ); |
632 | 650 | } |
633 | 651 |
|
634 | 652 | #[test_case::test_case(TOKEN_PROGRAM_ID ; "p-token")] |
@@ -728,5 +746,11 @@ async fn fail_withdraw_excess_lamports_from_multisig_missing_signer(token_progra |
728 | 746 |
|
729 | 747 | // The we expect an error. |
730 | 748 |
|
731 | | - assert_instruction_error!(error, InstructionError::MissingRequiredSignature); |
| 749 | + assert_matches!( |
| 750 | + error, |
| 751 | + BanksClientError::TransactionError(TransactionError::InstructionError( |
| 752 | + _, |
| 753 | + InstructionError::MissingRequiredSignature |
| 754 | + )) |
| 755 | + ); |
732 | 756 | } |
0 commit comments