Move validator_block_0_fee_workaround into TestValidator
This commit is contained in:
parent
bbad3fe501
commit
4fba7e6865
|
@ -244,6 +244,29 @@ impl TestValidator {
|
||||||
// test validators concurrently...
|
// test validators concurrently...
|
||||||
discover_cluster(&gossip, 1).expect("TestValidator startup failed");
|
discover_cluster(&gossip, 1).expect("TestValidator startup failed");
|
||||||
|
|
||||||
|
// This is a hack to delay until the single gossip commitment fees are non-zero for test
|
||||||
|
// consistency
|
||||||
|
// (fees from genesis are zero until the first block with a transaction in it is completed)
|
||||||
|
{
|
||||||
|
let rpc_client =
|
||||||
|
RpcClient::new_with_commitment(rpc_url.clone(), CommitmentConfig::single_gossip());
|
||||||
|
let fee_rate_governor = rpc_client
|
||||||
|
.get_fee_rate_governor()
|
||||||
|
.expect("get_fee_rate_governor")
|
||||||
|
.value;
|
||||||
|
if fee_rate_governor.target_lamports_per_signature > 0 {
|
||||||
|
while rpc_client
|
||||||
|
.get_recent_blockhash()
|
||||||
|
.expect("get_recent_blockhash")
|
||||||
|
.1
|
||||||
|
.lamports_per_signature
|
||||||
|
== 0
|
||||||
|
{
|
||||||
|
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(TestValidator {
|
Ok(TestValidator {
|
||||||
ledger_path: ledger_path.to_path_buf(),
|
ledger_path: ledger_path.to_path_buf(),
|
||||||
preserve_ledger: false,
|
preserve_ledger: false,
|
||||||
|
|
|
@ -1036,25 +1036,9 @@ pub fn test_process_distribute_stake_with_client(client: &RpcClient, sender_keyp
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_core::test_validator::TestValidator;
|
use solana_core::test_validator::TestValidator;
|
||||||
use solana_sdk::{
|
use solana_sdk::signature::{read_keypair_file, write_keypair_file, Signer};
|
||||||
clock::DEFAULT_MS_PER_SLOT,
|
|
||||||
signature::{read_keypair_file, write_keypair_file, Signer},
|
|
||||||
};
|
|
||||||
use solana_stake_program::stake_instruction::StakeInstruction;
|
use solana_stake_program::stake_instruction::StakeInstruction;
|
||||||
|
|
||||||
// This is a quick hack until TestValidator can be initialized with fees from block 0
|
|
||||||
fn test_validator_block_0_fee_workaround(client: &RpcClient) {
|
|
||||||
while client
|
|
||||||
.get_recent_blockhash()
|
|
||||||
.unwrap()
|
|
||||||
.1
|
|
||||||
.lamports_per_signature
|
|
||||||
== 0
|
|
||||||
{
|
|
||||||
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_process_token_allocations() {
|
fn test_process_token_allocations() {
|
||||||
let alice = Keypair::new();
|
let alice = Keypair::new();
|
||||||
|
@ -1400,8 +1384,6 @@ mod tests {
|
||||||
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
||||||
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
||||||
|
|
||||||
test_validator_block_0_fee_workaround(&client);
|
|
||||||
|
|
||||||
let allocation_amount = 1000.0;
|
let allocation_amount = 1000.0;
|
||||||
|
|
||||||
// Fully funded payer
|
// Fully funded payer
|
||||||
|
@ -1482,7 +1464,6 @@ mod tests {
|
||||||
let url = test_validator.rpc_url();
|
let url = test_validator.rpc_url();
|
||||||
|
|
||||||
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
||||||
test_validator_block_0_fee_workaround(&client);
|
|
||||||
|
|
||||||
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
||||||
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
||||||
|
@ -1592,7 +1573,6 @@ mod tests {
|
||||||
let test_validator = TestValidator::with_custom_fees(alice.pubkey(), fees);
|
let test_validator = TestValidator::with_custom_fees(alice.pubkey(), fees);
|
||||||
let url = test_validator.rpc_url();
|
let url = test_validator.rpc_url();
|
||||||
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
||||||
test_validator_block_0_fee_workaround(&client);
|
|
||||||
|
|
||||||
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
||||||
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
||||||
|
@ -1700,7 +1680,6 @@ mod tests {
|
||||||
let url = test_validator.rpc_url();
|
let url = test_validator.rpc_url();
|
||||||
|
|
||||||
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
let client = RpcClient::new_with_commitment(url, CommitmentConfig::recent());
|
||||||
test_validator_block_0_fee_workaround(&client);
|
|
||||||
|
|
||||||
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
let sender_keypair_file = tmp_file_path("keypair_file", &alice.pubkey());
|
||||||
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
write_keypair_file(&alice, &sender_keypair_file).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue