From 9b802c5d3338041126cf879a01dae090470495e4 Mon Sep 17 00:00:00 2001 From: Jonas Hahn Date: Tue, 29 Oct 2024 15:20:44 +0100 Subject: [PATCH] Add skip preflight to transfer + tests --- cli/tests/transfer.rs | 12 ++++++++---- rpc-client/src/nonblocking/rpc_client.rs | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/tests/transfer.rs b/cli/tests/transfer.rs index b1a750972543e1..378f758717c54f 100644 --- a/cli/tests/transfer.rs +++ b/cli/tests/transfer.rs @@ -26,8 +26,9 @@ use { test_case::test_case, }; -#[test] -fn test_transfer() { +#[test_case(true; "Skip Preflight")] +#[test_case(false; "Don`t skip Preflight")] +fn test_transfer(skip_preflight: bool) { solana_logger::setup(); let fee_one_sig = FeeStructure::default().get_max_fee(1, 0); let fee_two_sig = FeeStructure::default().get_max_fee(2, 0); @@ -50,6 +51,7 @@ fn test_transfer() { let mut config = CliConfig::recent_for_tests(); config.json_rpc_url = test_validator.rpc_url(); config.signers = vec![&default_signer]; + config.send_transaction_config.skip_preflight = skip_preflight; let sender_pubkey = config.signers[0].pubkey(); let recipient_pubkey = Pubkey::from([1u8; 32]); @@ -556,8 +558,9 @@ fn test_transfer_all(compute_unit_price: Option) { check_balance!(500_000 - fee, &rpc_client, &recipient_pubkey); } -#[test] -fn test_transfer_unfunded_recipient() { +#[test_case(true; "Skip Preflight")] +#[test_case(false; "Don`t skip Preflight")] +fn test_transfer_unfunded_recipient(skip_preflight: bool) { solana_logger::setup(); let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); @@ -577,6 +580,7 @@ fn test_transfer_unfunded_recipient() { let mut config = CliConfig::recent_for_tests(); config.json_rpc_url = test_validator.rpc_url(); config.signers = vec![&default_signer]; + config.send_transaction_config.skip_preflight = skip_preflight; let sender_pubkey = config.signers[0].pubkey(); let recipient_pubkey = Pubkey::from([1u8; 32]); diff --git a/rpc-client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs index b72b4a5d74a9c5..7f684d87d22165 100644 --- a/rpc-client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -868,6 +868,7 @@ impl RpcClient { }; let config = RpcSendTransactionConfig { encoding: Some(encoding), + skip_preflight: config.skip_preflight, preflight_commitment: Some(preflight_commitment.commitment), ..config };