nit: Traceable balance checks (#22462)
This commit is contained in:
parent
2756abce39
commit
1632ee03da
|
@ -1,23 +1,29 @@
|
||||||
use {
|
use {
|
||||||
solana_client::rpc_client::RpcClient,
|
solana_client::rpc_client::RpcClient,
|
||||||
solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig, pubkey::Pubkey},
|
solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig},
|
||||||
std::{thread::sleep, time::Duration},
|
std::{thread::sleep, time::Duration},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
#[macro_export]
|
||||||
|
macro_rules! check_balance {
|
||||||
|
($expected_balance:expr, $client:expr, $pubkey:expr) => {
|
||||||
(0..5).for_each(|tries| {
|
(0..5).for_each(|tries| {
|
||||||
let balance = client
|
let balance = $client
|
||||||
.get_balance_with_commitment(pubkey, CommitmentConfig::processed())
|
.get_balance_with_commitment($pubkey, CommitmentConfig::processed())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.value;
|
.value;
|
||||||
if balance == expected_balance {
|
if balance == $expected_balance {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if tries == 4 {
|
if tries == 4 {
|
||||||
assert_eq!(balance, expected_balance);
|
assert_eq!(balance, $expected_balance);
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(500));
|
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
($expected_balance:expr, $client:expr, $pubkey:expr,) => {
|
||||||
|
check_balance!($expected_balance, $client, $pubkey)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_ready(rpc_client: &RpcClient) {
|
pub fn check_ready(rpc_client: &RpcClient) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use {
|
use {
|
||||||
solana_cli::{
|
solana_cli::{
|
||||||
|
check_balance,
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
spend_utils::SpendAmount,
|
spend_utils::SpendAmount,
|
||||||
test_utils::{check_ready, check_recent_balance},
|
test_utils::check_ready,
|
||||||
},
|
},
|
||||||
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
|
@ -77,7 +79,7 @@ fn full_battery_tests(
|
||||||
sol_to_lamports(2000.0),
|
sol_to_lamports(2000.0),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(2000.0),
|
sol_to_lamports(2000.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
|
@ -117,12 +119,12 @@ fn full_battery_tests(
|
||||||
};
|
};
|
||||||
|
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1000.0),
|
sol_to_lamports(1000.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(1000.0), &rpc_client, &nonce_account);
|
check_balance!(sol_to_lamports(1000.0), &rpc_client, &nonce_account);
|
||||||
|
|
||||||
// Get nonce
|
// Get nonce
|
||||||
config_payer.signers.pop();
|
config_payer.signers.pop();
|
||||||
|
@ -173,13 +175,13 @@ fn full_battery_tests(
|
||||||
lamports: sol_to_lamports(100.0),
|
lamports: sol_to_lamports(100.0),
|
||||||
};
|
};
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1000.0),
|
sol_to_lamports(1000.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(900.0), &rpc_client, &nonce_account);
|
check_balance!(sol_to_lamports(900.0), &rpc_client, &nonce_account);
|
||||||
check_recent_balance(sol_to_lamports(100.0), &rpc_client, &payee_pubkey);
|
check_balance!(sol_to_lamports(100.0), &rpc_client, &payee_pubkey);
|
||||||
|
|
||||||
// Show nonce account
|
// Show nonce account
|
||||||
config_payer.command = CliCommand::ShowNonceAccount {
|
config_payer.command = CliCommand::ShowNonceAccount {
|
||||||
|
@ -224,13 +226,13 @@ fn full_battery_tests(
|
||||||
lamports: sol_to_lamports(100.0),
|
lamports: sol_to_lamports(100.0),
|
||||||
};
|
};
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1000.0),
|
sol_to_lamports(1000.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&config_payer.signers[0].pubkey(),
|
&config_payer.signers[0].pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(800.0), &rpc_client, &nonce_account);
|
check_balance!(sol_to_lamports(800.0), &rpc_client, &nonce_account);
|
||||||
check_recent_balance(sol_to_lamports(200.0), &rpc_client, &payee_pubkey);
|
check_balance!(sol_to_lamports(200.0), &rpc_client, &payee_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -268,17 +270,17 @@ fn test_create_account_with_seed() {
|
||||||
sol_to_lamports(4242.0),
|
sol_to_lamports(4242.0),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(42.0),
|
sol_to_lamports(42.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_nonce_authority_signer.pubkey(),
|
&offline_nonce_authority_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(4242.0),
|
sol_to_lamports(4242.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&online_nonce_creator_signer.pubkey(),
|
&online_nonce_creator_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(0, &rpc_client, &to_address);
|
check_balance!(0, &rpc_client, &to_address);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -288,7 +290,7 @@ fn test_create_account_with_seed() {
|
||||||
let seed = authority_pubkey.to_string()[0..32].to_string();
|
let seed = authority_pubkey.to_string()[0..32].to_string();
|
||||||
let nonce_address =
|
let nonce_address =
|
||||||
Pubkey::create_with_seed(&creator_pubkey, &seed, &system_program::id()).unwrap();
|
Pubkey::create_with_seed(&creator_pubkey, &seed, &system_program::id()).unwrap();
|
||||||
check_recent_balance(0, &rpc_client, &nonce_address);
|
check_balance!(0, &rpc_client, &nonce_address);
|
||||||
|
|
||||||
let mut creator_config = CliConfig::recent_for_tests();
|
let mut creator_config = CliConfig::recent_for_tests();
|
||||||
creator_config.json_rpc_url = test_validator.rpc_url();
|
creator_config.json_rpc_url = test_validator.rpc_url();
|
||||||
|
@ -301,18 +303,18 @@ fn test_create_account_with_seed() {
|
||||||
amount: SpendAmount::Some(sol_to_lamports(241.0)),
|
amount: SpendAmount::Some(sol_to_lamports(241.0)),
|
||||||
};
|
};
|
||||||
process_command(&creator_config).unwrap();
|
process_command(&creator_config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(241.0), &rpc_client, &nonce_address);
|
check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(42.0),
|
sol_to_lamports(42.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_nonce_authority_signer.pubkey(),
|
&offline_nonce_authority_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(4000.999999999),
|
sol_to_lamports(4000.999999999),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&online_nonce_creator_signer.pubkey(),
|
&online_nonce_creator_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(0, &rpc_client, &to_address);
|
check_balance!(0, &rpc_client, &to_address);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let nonce_hash = nonce_utils::get_account_with_commitment(
|
let nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
|
@ -377,16 +379,16 @@ fn test_create_account_with_seed() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&submit_config).unwrap();
|
process_command(&submit_config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(241.0), &rpc_client, &nonce_address);
|
check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(31.999999999),
|
sol_to_lamports(31.999999999),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_nonce_authority_signer.pubkey(),
|
&offline_nonce_authority_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(4000.999999999),
|
sol_to_lamports(4000.999999999),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&online_nonce_creator_signer.pubkey(),
|
&online_nonce_creator_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(10.0), &rpc_client, &to_address);
|
check_balance!(sol_to_lamports(10.0), &rpc_client, &to_address);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use {
|
use {
|
||||||
serde_json::Value,
|
serde_json::Value,
|
||||||
solana_cli::{
|
solana_cli::{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use {
|
use {
|
||||||
solana_cli::cli::{process_command, CliCommand, CliConfig},
|
solana_cli::cli::{process_command, CliCommand, CliConfig},
|
||||||
solana_client::rpc_client::RpcClient,
|
solana_client::rpc_client::RpcClient,
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
#![allow(clippy::redundant_closure)]
|
#![allow(clippy::redundant_closure)]
|
||||||
use {
|
use {
|
||||||
solana_cli::{
|
solana_cli::{
|
||||||
|
check_balance,
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
spend_utils::SpendAmount,
|
spend_utils::SpendAmount,
|
||||||
stake::StakeAuthorizationIndexed,
|
stake::StakeAuthorizationIndexed,
|
||||||
test_utils::{check_ready, check_recent_balance},
|
test_utils::check_ready,
|
||||||
},
|
},
|
||||||
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
|
@ -150,7 +152,7 @@ fn test_seed_stake_delegation_and_deactivation() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
|
|
||||||
let stake_address = Pubkey::create_with_seed(
|
let stake_address = Pubkey::create_with_seed(
|
||||||
&config_validator.signers[0].pubkey(),
|
&config_validator.signers[0].pubkey(),
|
||||||
|
@ -239,7 +241,7 @@ fn test_stake_delegation_and_deactivation() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
|
|
||||||
// Create stake account
|
// Create stake account
|
||||||
config_validator.signers.push(&stake_keypair);
|
config_validator.signers.push(&stake_keypair);
|
||||||
|
@ -333,7 +335,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_validator.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(
|
request_and_confirm_airdrop(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
|
@ -342,7 +344,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
||||||
|
|
||||||
// Create stake account
|
// Create stake account
|
||||||
config_validator.signers.push(&stake_keypair);
|
config_validator.signers.push(&stake_keypair);
|
||||||
|
@ -911,13 +913,13 @@ fn test_stake_authorize_with_fee_payer() {
|
||||||
process_command(&config_offline).unwrap_err();
|
process_command(&config_offline).unwrap_err();
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &default_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config, &default_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config_payer, &payer_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config_payer, &payer_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &payer_pubkey);
|
check_balance!(100_000, &rpc_client, &payer_pubkey);
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance!(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -944,7 +946,7 @@ fn test_stake_authorize_with_fee_payer() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
// `config` balance should be 50,000 - 1 stake account sig - 1 fee sig
|
// `config` balance should be 50,000 - 1 stake account sig - 1 fee sig
|
||||||
check_recent_balance(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
check_balance!(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
||||||
|
|
||||||
// Assign authority with separate fee payer
|
// Assign authority with separate fee payer
|
||||||
config.signers = vec![&default_signer, &payer_keypair];
|
config.signers = vec![&default_signer, &payer_keypair];
|
||||||
|
@ -968,10 +970,10 @@ fn test_stake_authorize_with_fee_payer() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
// `config` balance has not changed, despite submitting the TX
|
// `config` balance has not changed, despite submitting the TX
|
||||||
check_recent_balance(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
check_balance!(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
||||||
// `config_payer` however has paid `config`'s authority sig
|
// `config_payer` however has paid `config`'s authority sig
|
||||||
// and `config_payer`'s fee sig
|
// and `config_payer`'s fee sig
|
||||||
check_recent_balance(100_000 - SIG_FEE - SIG_FEE, &rpc_client, &payer_pubkey);
|
check_balance!(100_000 - SIG_FEE - SIG_FEE, &rpc_client, &payer_pubkey);
|
||||||
|
|
||||||
// Assign authority with offline fee payer
|
// Assign authority with offline fee payer
|
||||||
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
||||||
|
@ -1019,10 +1021,10 @@ fn test_stake_authorize_with_fee_payer() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
// `config`'s balance again has not changed
|
// `config`'s balance again has not changed
|
||||||
check_recent_balance(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
check_balance!(50_000 - SIG_FEE - SIG_FEE, &rpc_client, &default_pubkey);
|
||||||
// `config_offline` however has paid 1 sig due to being both authority
|
// `config_offline` however has paid 1 sig due to being both authority
|
||||||
// and fee payer
|
// and fee payer
|
||||||
check_recent_balance(100_000 - SIG_FEE, &rpc_client, &offline_pubkey);
|
check_balance!(100_000 - SIG_FEE, &rpc_client, &offline_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1058,10 +1060,10 @@ fn test_stake_split() {
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 500_000)
|
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 500_000)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance!(500_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance!(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create stake account, identity is authority
|
// Create stake account, identity is authority
|
||||||
let minimum_stake_balance = rpc_client
|
let minimum_stake_balance = rpc_client
|
||||||
|
@ -1088,7 +1090,7 @@ fn test_stake_split() {
|
||||||
from: 0,
|
from: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
10 * minimum_stake_balance,
|
10 * minimum_stake_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&stake_account_pubkey,
|
&stake_account_pubkey,
|
||||||
|
@ -1108,7 +1110,7 @@ fn test_stake_split() {
|
||||||
amount: SpendAmount::Some(minimum_nonce_balance),
|
amount: SpendAmount::Some(minimum_nonce_balance),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(minimum_nonce_balance, &rpc_client, &nonce_account.pubkey());
|
check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account.pubkey());
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let nonce_hash = nonce_utils::get_account_with_commitment(
|
let nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
|
@ -1122,7 +1124,7 @@ fn test_stake_split() {
|
||||||
|
|
||||||
// Nonced offline split
|
// Nonced offline split
|
||||||
let split_account = keypair_from_seed(&[2u8; 32]).unwrap();
|
let split_account = keypair_from_seed(&[2u8; 32]).unwrap();
|
||||||
check_recent_balance(0, &rpc_client, &split_account.pubkey());
|
check_balance!(0, &rpc_client, &split_account.pubkey());
|
||||||
config_offline.signers.push(&split_account);
|
config_offline.signers.push(&split_account);
|
||||||
config_offline.command = CliCommand::SplitStake {
|
config_offline.command = CliCommand::SplitStake {
|
||||||
stake_account_pubkey,
|
stake_account_pubkey,
|
||||||
|
@ -1162,12 +1164,12 @@ fn test_stake_split() {
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
8 * minimum_stake_balance,
|
8 * minimum_stake_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&stake_account_pubkey,
|
&stake_account_pubkey,
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
2 * minimum_stake_balance,
|
2 * minimum_stake_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&split_account.pubkey(),
|
&split_account.pubkey(),
|
||||||
|
@ -1207,10 +1209,10 @@ fn test_stake_set_lockup() {
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 500_000)
|
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 500_000)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(500_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance!(500_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance!(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create stake account, identity is authority
|
// Create stake account, identity is authority
|
||||||
let minimum_stake_balance = rpc_client
|
let minimum_stake_balance = rpc_client
|
||||||
|
@ -1244,7 +1246,12 @@ fn test_stake_set_lockup() {
|
||||||
from: 0,
|
from: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
|
10 * minimum_stake_balance,
|
||||||
|
&rpc_client,
|
||||||
|
&stake_account_pubkey,
|
||||||
|
);
|
||||||
|
check_balance!(
|
||||||
10 * minimum_stake_balance,
|
10 * minimum_stake_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&stake_account_pubkey,
|
&stake_account_pubkey,
|
||||||
|
@ -1377,7 +1384,7 @@ fn test_stake_set_lockup() {
|
||||||
amount: SpendAmount::Some(minimum_nonce_balance),
|
amount: SpendAmount::Some(minimum_nonce_balance),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(minimum_nonce_balance, &rpc_client, &nonce_account_pubkey);
|
check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account_pubkey);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let nonce_hash = nonce_utils::get_account_with_commitment(
|
let nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
|
@ -1473,10 +1480,10 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 200_000)
|
request_and_confirm_airdrop(&rpc_client, &config, &config.signers[0].pubkey(), 200_000)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(200_000, &rpc_client, &config.signers[0].pubkey());
|
check_balance!(200_000, &rpc_client, &config.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config_offline, &offline_pubkey, 100_000).unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &offline_pubkey);
|
check_balance!(100_000, &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Create nonce account
|
// Create nonce account
|
||||||
let minimum_nonce_balance = rpc_client
|
let minimum_nonce_balance = rpc_client
|
||||||
|
@ -1553,7 +1560,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
||||||
from: 0,
|
from: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(50_000, &rpc_client, &stake_pubkey);
|
check_balance!(50_000, &rpc_client, &stake_pubkey);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let nonce_hash = nonce_utils::get_account_with_commitment(
|
let nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
|
@ -1607,7 +1614,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(50_000, &rpc_client, &recipient_pubkey);
|
check_balance!(50_000, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let nonce_hash = nonce_utils::get_account_with_commitment(
|
let nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
|
@ -1667,7 +1674,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
let seed_address =
|
let seed_address =
|
||||||
Pubkey::create_with_seed(&stake_pubkey, seed, &stake::program::id()).unwrap();
|
Pubkey::create_with_seed(&stake_pubkey, seed, &stake::program::id()).unwrap();
|
||||||
check_recent_balance(50_000, &rpc_client, &seed_address);
|
check_balance!(50_000, &rpc_client, &seed_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
#![allow(clippy::redundant_closure)]
|
#![allow(clippy::redundant_closure)]
|
||||||
use {
|
use {
|
||||||
solana_cli::{
|
solana_cli::{
|
||||||
|
check_balance,
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
spend_utils::SpendAmount,
|
spend_utils::SpendAmount,
|
||||||
test_utils::{check_ready, check_recent_balance},
|
test_utils::check_ready,
|
||||||
},
|
},
|
||||||
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
|
@ -52,8 +54,8 @@ fn test_transfer() {
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, sol_to_lamports(5.0))
|
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, sol_to_lamports(5.0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(sol_to_lamports(5.0), &rpc_client, &sender_pubkey);
|
check_balance!(sol_to_lamports(5.0), &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(0, &rpc_client, &recipient_pubkey);
|
check_balance!(0, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -75,8 +77,8 @@ fn test_transfer() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(4.0) - 1, &rpc_client, &sender_pubkey);
|
check_balance!(sol_to_lamports(4.0) - 1, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(1.0), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(1.0), &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
// Plain ole transfer, failure due to InsufficientFundsForSpendAndFee
|
// Plain ole transfer, failure due to InsufficientFundsForSpendAndFee
|
||||||
config.command = CliCommand::Transfer {
|
config.command = CliCommand::Transfer {
|
||||||
|
@ -96,8 +98,8 @@ fn test_transfer() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
assert!(process_command(&config).is_err());
|
assert!(process_command(&config).is_err());
|
||||||
check_recent_balance(sol_to_lamports(4.0) - 1, &rpc_client, &sender_pubkey);
|
check_balance!(sol_to_lamports(4.0) - 1, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(1.0), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(1.0), &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
let mut offline = CliConfig::recent_for_tests();
|
let mut offline = CliConfig::recent_for_tests();
|
||||||
offline.json_rpc_url = String::default();
|
offline.json_rpc_url = String::default();
|
||||||
|
@ -109,7 +111,7 @@ fn test_transfer() {
|
||||||
let offline_pubkey = offline.signers[0].pubkey();
|
let offline_pubkey = offline.signers[0].pubkey();
|
||||||
request_and_confirm_airdrop(&rpc_client, &offline, &offline_pubkey, sol_to_lamports(1.0))
|
request_and_confirm_airdrop(&rpc_client, &offline, &offline_pubkey, sol_to_lamports(1.0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(sol_to_lamports(1.0), &rpc_client, &offline_pubkey);
|
check_balance!(sol_to_lamports(1.0), &rpc_client, &offline_pubkey);
|
||||||
|
|
||||||
// Offline transfer
|
// Offline transfer
|
||||||
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
||||||
|
@ -152,8 +154,8 @@ fn test_transfer() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(0.5) - 1, &rpc_client, &offline_pubkey);
|
check_balance!(sol_to_lamports(0.5) - 1, &rpc_client, &offline_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(1.5), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(1.5), &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
// Create nonce account
|
// Create nonce account
|
||||||
let nonce_account = keypair_from_seed(&[3u8; 32]).unwrap();
|
let nonce_account = keypair_from_seed(&[3u8; 32]).unwrap();
|
||||||
|
@ -169,7 +171,7 @@ fn test_transfer() {
|
||||||
amount: SpendAmount::Some(minimum_nonce_balance),
|
amount: SpendAmount::Some(minimum_nonce_balance),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(4.0) - 3 - minimum_nonce_balance,
|
sol_to_lamports(4.0) - 3 - minimum_nonce_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&sender_pubkey,
|
&sender_pubkey,
|
||||||
|
@ -207,12 +209,12 @@ fn test_transfer() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(3.0) - 4 - minimum_nonce_balance,
|
sol_to_lamports(3.0) - 4 - minimum_nonce_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&sender_pubkey,
|
&sender_pubkey,
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(2.5), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(2.5), &rpc_client, &recipient_pubkey);
|
||||||
let new_nonce_hash = nonce_utils::get_account_with_commitment(
|
let new_nonce_hash = nonce_utils::get_account_with_commitment(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&nonce_account.pubkey(),
|
&nonce_account.pubkey(),
|
||||||
|
@ -232,7 +234,7 @@ fn test_transfer() {
|
||||||
new_authority: offline_pubkey,
|
new_authority: offline_pubkey,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(3.0) - 5 - minimum_nonce_balance,
|
sol_to_lamports(3.0) - 5 - minimum_nonce_balance,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&sender_pubkey,
|
&sender_pubkey,
|
||||||
|
@ -291,8 +293,8 @@ fn test_transfer() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(0.1) - 2, &rpc_client, &offline_pubkey);
|
check_balance!(sol_to_lamports(0.1) - 2, &rpc_client, &offline_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(2.9), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(2.9), &rpc_client, &recipient_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -330,17 +332,17 @@ fn test_transfer_multisession_signing() {
|
||||||
sol_to_lamports(1.0) + 3,
|
sol_to_lamports(1.0) + 3,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(43.0),
|
sol_to_lamports(43.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_from_signer.pubkey(),
|
&offline_from_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1.0) + 3,
|
sol_to_lamports(1.0) + 3,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_fee_payer_signer.pubkey(),
|
&offline_fee_payer_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(0, &rpc_client, &to_pubkey);
|
check_balance!(0, &rpc_client, &to_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -430,17 +432,17 @@ fn test_transfer_multisession_signing() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
|
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1.0),
|
sol_to_lamports(1.0),
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_from_signer.pubkey(),
|
&offline_from_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(
|
check_balance!(
|
||||||
sol_to_lamports(1.0) + 1,
|
sol_to_lamports(1.0) + 1,
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
&offline_fee_payer_signer.pubkey(),
|
&offline_fee_payer_signer.pubkey(),
|
||||||
);
|
);
|
||||||
check_recent_balance(sol_to_lamports(42.0), &rpc_client, &to_pubkey);
|
check_balance!(sol_to_lamports(42.0), &rpc_client, &to_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -469,8 +471,8 @@ fn test_transfer_all() {
|
||||||
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, 50_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, 50_000).unwrap();
|
||||||
check_recent_balance(50_000, &rpc_client, &sender_pubkey);
|
check_balance!(50_000, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(0, &rpc_client, &recipient_pubkey);
|
check_balance!(0, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -492,8 +494,8 @@ fn test_transfer_all() {
|
||||||
derived_address_program_id: None,
|
derived_address_program_id: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(0, &rpc_client, &sender_pubkey);
|
check_balance!(0, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(49_999, &rpc_client, &recipient_pubkey);
|
check_balance!(49_999, &rpc_client, &recipient_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -522,8 +524,8 @@ fn test_transfer_unfunded_recipient() {
|
||||||
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
let recipient_pubkey = Pubkey::new(&[1u8; 32]);
|
||||||
|
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, 50_000).unwrap();
|
request_and_confirm_airdrop(&rpc_client, &config, &sender_pubkey, 50_000).unwrap();
|
||||||
check_recent_balance(50_000, &rpc_client, &sender_pubkey);
|
check_balance!(50_000, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(0, &rpc_client, &recipient_pubkey);
|
check_balance!(0, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -586,9 +588,9 @@ fn test_transfer_with_seed() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
request_and_confirm_airdrop(&rpc_client, &config, &derived_address, sol_to_lamports(5.0))
|
request_and_confirm_airdrop(&rpc_client, &config, &derived_address, sol_to_lamports(5.0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(sol_to_lamports(1.0), &rpc_client, &sender_pubkey);
|
check_balance!(sol_to_lamports(1.0), &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(5.0), &rpc_client, &derived_address);
|
check_balance!(sol_to_lamports(5.0), &rpc_client, &derived_address);
|
||||||
check_recent_balance(0, &rpc_client, &recipient_pubkey);
|
check_balance!(0, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
check_ready(&rpc_client);
|
check_ready(&rpc_client);
|
||||||
|
|
||||||
|
@ -610,7 +612,7 @@ fn test_transfer_with_seed() {
|
||||||
derived_address_program_id: Some(derived_address_program_id),
|
derived_address_program_id: Some(derived_address_program_id),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(sol_to_lamports(1.0) - 1, &rpc_client, &sender_pubkey);
|
check_balance!(sol_to_lamports(1.0) - 1, &rpc_client, &sender_pubkey);
|
||||||
check_recent_balance(sol_to_lamports(5.0), &rpc_client, &recipient_pubkey);
|
check_balance!(sol_to_lamports(5.0), &rpc_client, &recipient_pubkey);
|
||||||
check_recent_balance(0, &rpc_client, &derived_address);
|
check_balance!(0, &rpc_client, &derived_address);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use {
|
use {
|
||||||
solana_cli::{
|
solana_cli::{
|
||||||
|
check_balance,
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
spend_utils::SpendAmount,
|
spend_utils::SpendAmount,
|
||||||
test_utils::check_recent_balance,
|
|
||||||
},
|
},
|
||||||
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
|
@ -69,7 +70,7 @@ fn test_vote_authorize_and_withdraw() {
|
||||||
.get_minimum_balance_for_rent_exemption(VoteState::size_of())
|
.get_minimum_balance_for_rent_exemption(VoteState::size_of())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.max(1);
|
.max(1);
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
|
|
||||||
// Transfer in some more SOL
|
// Transfer in some more SOL
|
||||||
config.signers = vec![&default_signer];
|
config.signers = vec![&default_signer];
|
||||||
|
@ -91,7 +92,7 @@ fn test_vote_authorize_and_withdraw() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
let expected_balance = expected_balance + 10_000;
|
let expected_balance = expected_balance + 10_000;
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
|
|
||||||
// Authorize vote account withdrawal to another signer
|
// Authorize vote account withdrawal to another signer
|
||||||
let first_withdraw_authority = Keypair::new();
|
let first_withdraw_authority = Keypair::new();
|
||||||
|
@ -181,8 +182,8 @@ fn test_vote_authorize_and_withdraw() {
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
let expected_balance = expected_balance - 1_000;
|
let expected_balance = expected_balance - 1_000;
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
check_recent_balance(1_000, &rpc_client, &destination_account);
|
check_balance!(1_000, &rpc_client, &destination_account);
|
||||||
|
|
||||||
// Re-assign validator identity
|
// Re-assign validator identity
|
||||||
let new_identity_keypair = Keypair::new();
|
let new_identity_keypair = Keypair::new();
|
||||||
|
@ -212,8 +213,8 @@ fn test_vote_authorize_and_withdraw() {
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_recent_balance(0, &rpc_client, &vote_account_pubkey);
|
check_balance!(0, &rpc_client, &vote_account_pubkey);
|
||||||
check_recent_balance(expected_balance, &rpc_client, &destination_account);
|
check_balance!(expected_balance, &rpc_client, &destination_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -247,7 +248,7 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_payer.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_payer.signers[0].pubkey());
|
||||||
|
|
||||||
request_and_confirm_airdrop(
|
request_and_confirm_airdrop(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
|
@ -256,7 +257,7 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
100_000,
|
100_000,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
check_recent_balance(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
check_balance!(100_000, &rpc_client, &config_offline.signers[0].pubkey());
|
||||||
|
|
||||||
// Create vote account with specific withdrawer
|
// Create vote account with specific withdrawer
|
||||||
let vote_account_keypair = Keypair::new();
|
let vote_account_keypair = Keypair::new();
|
||||||
|
@ -288,7 +289,7 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
.get_minimum_balance_for_rent_exemption(VoteState::size_of())
|
.get_minimum_balance_for_rent_exemption(VoteState::size_of())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.max(1);
|
.max(1);
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
|
|
||||||
// Transfer in some more SOL
|
// Transfer in some more SOL
|
||||||
config_payer.signers = vec![&default_signer];
|
config_payer.signers = vec![&default_signer];
|
||||||
|
@ -310,7 +311,7 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
};
|
};
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
let expected_balance = expected_balance + 10_000;
|
let expected_balance = expected_balance + 10_000;
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
|
|
||||||
// Authorize vote account withdrawal to another signer, offline
|
// Authorize vote account withdrawal to another signer, offline
|
||||||
let withdraw_authority = Keypair::new();
|
let withdraw_authority = Keypair::new();
|
||||||
|
@ -399,8 +400,8 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
};
|
};
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
let expected_balance = expected_balance - 1_000;
|
let expected_balance = expected_balance - 1_000;
|
||||||
check_recent_balance(expected_balance, &rpc_client, &vote_account_pubkey);
|
check_balance!(expected_balance, &rpc_client, &vote_account_pubkey);
|
||||||
check_recent_balance(1_000, &rpc_client, &destination_account);
|
check_balance!(1_000, &rpc_client, &destination_account);
|
||||||
|
|
||||||
// Re-assign validator identity offline
|
// Re-assign validator identity offline
|
||||||
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
let blockhash = rpc_client.get_latest_blockhash().unwrap();
|
||||||
|
@ -484,6 +485,6 @@ fn test_offline_vote_authorize_and_withdraw() {
|
||||||
fee_payer: 0,
|
fee_payer: 0,
|
||||||
};
|
};
|
||||||
process_command(&config_payer).unwrap();
|
process_command(&config_payer).unwrap();
|
||||||
check_recent_balance(0, &rpc_client, &vote_account_pubkey);
|
check_balance!(0, &rpc_client, &vote_account_pubkey);
|
||||||
check_recent_balance(expected_balance, &rpc_client, &destination_account);
|
check_balance!(expected_balance, &rpc_client, &destination_account);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue