Skip to content

Commit

Permalink
Add skip preflight to transfer + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Woody4618 committed Oct 29, 2024
1 parent 68a1b13 commit 9b802c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/tests/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);
Expand Down Expand Up @@ -556,8 +558,9 @@ fn test_transfer_all(compute_unit_price: Option<u64>) {
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();
Expand All @@ -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]);
Expand Down
1 change: 1 addition & 0 deletions rpc-client/src/nonblocking/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ impl RpcClient {
};
let config = RpcSendTransactionConfig {
encoding: Some(encoding),
skip_preflight: config.skip_preflight,
preflight_commitment: Some(preflight_commitment.commitment),
..config
};
Expand Down

0 comments on commit 9b802c5

Please sign in to comment.