harden cli tests (#34844)

harden cli tests by setting up TestValidator correctly
This commit is contained in:
Tao Zhu 2024-01-19 12:14:31 -06:00 committed by GitHub
parent 6835e10ba5
commit acef7baab6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View File

@ -249,7 +249,7 @@ fn test_create_account_with_seed() {
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, sol_to_lamports(ONE_SIG_FEE),
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );

View File

@ -1276,7 +1276,7 @@ fn test_stake_authorize_with_fee_payer() {
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, fee_one_sig,
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );

View File

@ -34,7 +34,7 @@ fn test_transfer() {
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, fee_one_sig,
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );
@ -325,13 +325,14 @@ fn test_transfer() {
#[test] #[test]
fn test_transfer_multisession_signing() { fn test_transfer_multisession_signing() {
solana_logger::setup(); 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_keypair = Keypair::new();
let mint_pubkey = mint_keypair.pubkey(); let mint_pubkey = mint_keypair.pubkey();
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, fee_one_sig,
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );
@ -355,7 +356,7 @@ fn test_transfer_multisession_signing() {
&rpc_client, &rpc_client,
&CliConfig::recent_for_tests(), &CliConfig::recent_for_tests(),
&offline_fee_payer_signer.pubkey(), &offline_fee_payer_signer.pubkey(),
sol_to_lamports(1.0) + 2 * fee, sol_to_lamports(1.0) + 2 * fee_two_sig,
) )
.unwrap(); .unwrap();
check_balance!( check_balance!(
@ -364,7 +365,7 @@ fn test_transfer_multisession_signing() {
&offline_from_signer.pubkey(), &offline_from_signer.pubkey(),
); );
check_balance!( check_balance!(
sol_to_lamports(1.0) + 2 * fee, sol_to_lamports(1.0) + 2 * fee_two_sig,
&rpc_client, &rpc_client,
&offline_fee_payer_signer.pubkey(), &offline_fee_payer_signer.pubkey(),
); );
@ -467,7 +468,7 @@ fn test_transfer_multisession_signing() {
&offline_from_signer.pubkey(), &offline_from_signer.pubkey(),
); );
check_balance!( check_balance!(
sol_to_lamports(1.0) + fee, sol_to_lamports(1.0) + fee_two_sig,
&rpc_client, &rpc_client,
&offline_fee_payer_signer.pubkey(), &offline_fee_payer_signer.pubkey(),
); );
@ -483,7 +484,7 @@ fn test_transfer_all() {
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, fee,
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );
@ -592,7 +593,7 @@ fn test_transfer_with_seed() {
let faucet_addr = run_local_faucet(mint_keypair, None); let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator = TestValidator::with_custom_fees( let test_validator = TestValidator::with_custom_fees(
mint_pubkey, mint_pubkey,
1, fee,
Some(faucet_addr), Some(faucet_addr),
SocketAddrSpace::Unspecified, SocketAddrSpace::Unspecified,
); );