@ -806,12 +806,11 @@ fn check_account_for_multiple_fees(
|
|||||||
) -> Result<(), Box<dyn error::Error>> {
|
) -> Result<(), Box<dyn error::Error>> {
|
||||||
let balance = rpc_client.retry_get_balance(account_pubkey, 5)?;
|
let balance = rpc_client.retry_get_balance(account_pubkey, 5)?;
|
||||||
if let Some(lamports) = balance {
|
if let Some(lamports) = balance {
|
||||||
if lamports
|
let fee = messages
|
||||||
>= messages
|
.iter()
|
||||||
.iter()
|
.map(|message| fee_calculator.calculate_fee(message))
|
||||||
.map(|message| fee_calculator.calculate_fee(message))
|
.sum();
|
||||||
.sum()
|
if lamports != 0 && lamports >= fee {
|
||||||
{
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3199,7 +3198,6 @@ mod tests {
|
|||||||
};
|
};
|
||||||
assert!(process_command(&config).is_ok());
|
assert!(process_command(&config).is_ok());
|
||||||
|
|
||||||
config.rpc_client = Some(RpcClient::new_mock("airdrop".to_string()));
|
|
||||||
config.command = CliCommand::TimeElapsed(bob_pubkey, process_id, dt);
|
config.command = CliCommand::TimeElapsed(bob_pubkey, process_id, dt);
|
||||||
let signature = process_command(&config);
|
let signature = process_command(&config);
|
||||||
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
||||||
|
@ -15,7 +15,7 @@ use std::fs::remove_dir_all;
|
|||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use solana_core::validator::new_validator_for_tests;
|
use solana_core::validator::new_validator_for_tests_ex;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
@ -40,7 +40,7 @@ fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transfer() {
|
fn test_transfer() {
|
||||||
let (server, leader_data, mint_keypair, ledger_path) = new_validator_for_tests();
|
let (server, leader_data, mint_keypair, ledger_path, _) = new_validator_for_tests_ex(1, 42_000);
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
run_local_faucet(mint_keypair, sender, None);
|
run_local_faucet(mint_keypair, sender, None);
|
||||||
@ -73,7 +73,7 @@ fn test_transfer() {
|
|||||||
fee_payer: None,
|
fee_payer: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_balance(49_990, &rpc_client, &sender_pubkey);
|
check_balance(49_989, &rpc_client, &sender_pubkey);
|
||||||
check_balance(10, &rpc_client, &recipient_pubkey);
|
check_balance(10, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
let mut offline = CliConfig::default();
|
let mut offline = CliConfig::default();
|
||||||
@ -114,7 +114,7 @@ fn test_transfer() {
|
|||||||
fee_payer: Some(offline_pubkey.into()),
|
fee_payer: Some(offline_pubkey.into()),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_balance(40, &rpc_client, &offline_pubkey);
|
check_balance(39, &rpc_client, &offline_pubkey);
|
||||||
check_balance(20, &rpc_client, &recipient_pubkey);
|
check_balance(20, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
// Create nonce account
|
// Create nonce account
|
||||||
@ -131,6 +131,7 @@ fn test_transfer() {
|
|||||||
lamports: minimum_nonce_balance,
|
lamports: minimum_nonce_balance,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
|
check_balance(49_987 - minimum_nonce_balance, &rpc_client, &sender_pubkey);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
||||||
@ -153,7 +154,7 @@ fn test_transfer() {
|
|||||||
fee_payer: None,
|
fee_payer: None,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_balance(49_980 - minimum_nonce_balance, &rpc_client, &sender_pubkey);
|
check_balance(49_976 - minimum_nonce_balance, &rpc_client, &sender_pubkey);
|
||||||
check_balance(30, &rpc_client, &recipient_pubkey);
|
check_balance(30, &rpc_client, &recipient_pubkey);
|
||||||
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
||||||
let nonce_state: NonceState = account.state().unwrap();
|
let nonce_state: NonceState = account.state().unwrap();
|
||||||
@ -170,6 +171,7 @@ fn test_transfer() {
|
|||||||
new_authority: offline_pubkey,
|
new_authority: offline_pubkey,
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
|
check_balance(49_975 - minimum_nonce_balance, &rpc_client, &sender_pubkey);
|
||||||
|
|
||||||
// Fetch nonce hash
|
// Fetch nonce hash
|
||||||
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
let account = rpc_client.get_account(&nonce_account.pubkey()).unwrap();
|
||||||
@ -205,7 +207,7 @@ fn test_transfer() {
|
|||||||
fee_payer: Some(offline_pubkey.into()),
|
fee_payer: Some(offline_pubkey.into()),
|
||||||
};
|
};
|
||||||
process_command(&config).unwrap();
|
process_command(&config).unwrap();
|
||||||
check_balance(30, &rpc_client, &offline_pubkey);
|
check_balance(28, &rpc_client, &offline_pubkey);
|
||||||
check_balance(40, &rpc_client, &recipient_pubkey);
|
check_balance(40, &rpc_client, &recipient_pubkey);
|
||||||
|
|
||||||
server.close().unwrap();
|
server.close().unwrap();
|
||||||
|
@ -60,13 +60,10 @@ impl GenericRpcClientRequest for MockRpcClientRequest {
|
|||||||
Value::Null
|
Value::Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RpcRequest::GetBalance => {
|
RpcRequest::GetBalance => serde_json::to_value(Response {
|
||||||
let n = if self.url == "airdrop" { 0 } else { 50 };
|
context: RpcResponseContext { slot: 1 },
|
||||||
serde_json::to_value(Response {
|
value: Value::Number(Number::from(50)),
|
||||||
context: RpcResponseContext { slot: 1 },
|
})?,
|
||||||
value: Value::Number(Number::from(n)),
|
|
||||||
})?
|
|
||||||
}
|
|
||||||
RpcRequest::GetRecentBlockhash => serde_json::to_value(Response {
|
RpcRequest::GetRecentBlockhash => serde_json::to_value(Response {
|
||||||
context: RpcResponseContext { slot: 1 },
|
context: RpcResponseContext { slot: 1 },
|
||||||
value: (
|
value: (
|
||||||
|
Reference in New Issue
Block a user