Skip to content

Commit

Permalink
harden cli tests (solana-labs#34844)
Browse files Browse the repository at this point in the history
harden cli tests by setting up TestValidator correctly
  • Loading branch information
tao-stones authored Jan 19, 2024
1 parent 6835e10 commit acef7ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cli/tests/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn test_create_account_with_seed() {
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
sol_to_lamports(ONE_SIG_FEE),
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ fn test_stake_authorize_with_fee_payer() {
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
fee_one_sig,
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand Down
17 changes: 9 additions & 8 deletions cli/tests/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_transfer() {
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
fee_one_sig,
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand Down Expand Up @@ -325,13 +325,14 @@ fn test_transfer() {
#[test]
fn test_transfer_multisession_signing() {
solana_logger::setup();
let fee = FeeStructure::default().get_max_fee(2, 0);
let fee_one_sig = FeeStructure::default().get_max_fee(1, 0);
let fee_two_sig = FeeStructure::default().get_max_fee(2, 0);
let mint_keypair = Keypair::new();
let mint_pubkey = mint_keypair.pubkey();
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
fee_one_sig,
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand All @@ -355,7 +356,7 @@ fn test_transfer_multisession_signing() {
&rpc_client,
&CliConfig::recent_for_tests(),
&offline_fee_payer_signer.pubkey(),
sol_to_lamports(1.0) + 2 * fee,
sol_to_lamports(1.0) + 2 * fee_two_sig,
)
.unwrap();
check_balance!(
Expand All @@ -364,7 +365,7 @@ fn test_transfer_multisession_signing() {
&offline_from_signer.pubkey(),
);
check_balance!(
sol_to_lamports(1.0) + 2 * fee,
sol_to_lamports(1.0) + 2 * fee_two_sig,
&rpc_client,
&offline_fee_payer_signer.pubkey(),
);
Expand Down Expand Up @@ -467,7 +468,7 @@ fn test_transfer_multisession_signing() {
&offline_from_signer.pubkey(),
);
check_balance!(
sol_to_lamports(1.0) + fee,
sol_to_lamports(1.0) + fee_two_sig,
&rpc_client,
&offline_fee_payer_signer.pubkey(),
);
Expand All @@ -483,7 +484,7 @@ fn test_transfer_all() {
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
fee,
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand Down Expand Up @@ -592,7 +593,7 @@ fn test_transfer_with_seed() {
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees(
mint_pubkey,
1,
fee,
Some(faucet_addr),
SocketAddrSpace::Unspecified,
);
Expand Down

0 comments on commit acef7ba

Please sign in to comment.