Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

harden cli tests #34844

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? it says 2 * fee_two_sig which would be 4?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's original test logic :) I only rename the fee to fee_two_sig for consistency. It checks 2 * fee_two_sig at ln 368 below, feels intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read the test, it sign a two-signature transaction twice that transfers 42.0 sol. offline_fee_payer_signer is one of the signer (eg payer) that is initiated with 1 + 2 * fee_two_sig. After submitted transaction, it's balance should be original_balance - fee_for_two_sig_transaction = (1 + 2 * fee_two_sig) - fee_two_sig = 1 + fee_two_sig. Which it asserts at Ln#470:

    check_balance!(
        sol_to_lamports(1.0) + fee_two_sig,
        &rpc_client,
        &offline_fee_payer_signer.pubkey(),
    );

So you are right that offline_fee_payer_signer does not need to be initialized with 2 *. But the test is still valid, even a bit of confusing. Happy to straight it out separately.

)
.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