Populate test ledgers with a full slots to reduce test boilerplate

This commit is contained in:
Michael Vines
2019-02-26 16:35:00 -08:00
parent 033a04129a
commit 55a76ed4b0
9 changed files with 269 additions and 655 deletions

View File

@@ -10,7 +10,7 @@ extern crate solana;
use bincode::deserialize;
use solana::blocktree::{
create_tmp_sample_blocktree, get_tmp_ledger_path, tmp_copy_blocktree, Blocktree,
create_new_tmp_ledger, get_tmp_ledger_path, tmp_copy_blocktree, Blocktree,
};
use solana::client::mk_client;
use solana::cluster_info::{ClusterInfo, Node, NodeInfo};
@@ -47,8 +47,8 @@ fn test_replicator_startup_basic() {
let (genesis_block, mint_keypair) =
GenesisBlock::new_with_leader(1_000_000_000, leader_info.id, 42);
let (leader_ledger_path, _tick_height, _last_entry_height, _last_id, _last_entry_id) =
create_tmp_sample_blocktree(leader_ledger_path, &genesis_block, 0);
let (leader_ledger_path, _last_id) =
create_new_tmp_ledger(leader_ledger_path, &genesis_block).unwrap();
let validator_ledger_path = tmp_copy_blocktree!(&leader_ledger_path);
@@ -273,24 +273,22 @@ fn test_replicator_startup_leader_hang() {
#[test]
fn test_replicator_startup_ledger_hang() {
use std::net::UdpSocket;
solana_logger::setup();
info!("starting replicator test");
let leader_keypair = Arc::new(Keypair::new());
let (genesis_block, _mint_keypair) =
GenesisBlock::new_with_leader(100, leader_keypair.pubkey(), 42);
let (replicator_ledger_path, _tick_height, _last_entry_height, _last_id, _last_entry_id) =
create_tmp_sample_blocktree("replicator_test_replicator_ledger", &genesis_block, 0);
let (replicator_test_replicator_ledger, _last_id) =
create_new_tmp_ledger("replicator_test_replicator_ledger", &genesis_block).unwrap();
info!("starting leader node");
let leader_node = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_info = leader_node.info.clone();
let leader_ledger_path = "replicator_test_leader_ledger";
let (leader_ledger_path, _tick_height, _last_entry_height, _last_id, _last_entry_id) =
create_tmp_sample_blocktree(leader_ledger_path, &genesis_block, 0);
let (leader_ledger_path, _last_id) =
create_new_tmp_ledger(leader_ledger_path, &genesis_block).unwrap();
let validator_ledger_path = tmp_copy_blocktree!(&leader_ledger_path);
@@ -325,7 +323,7 @@ fn test_replicator_startup_ledger_hang() {
let mut replicator_node = Node::new_localhost_with_pubkey(bad_keys.pubkey());
// Pass bad TVU sockets to prevent successful ledger download
replicator_node.sockets.tvu = vec![UdpSocket::bind("0.0.0.0:0").unwrap()];
replicator_node.sockets.tvu = vec![std::net::UdpSocket::bind("0.0.0.0:0").unwrap()];
let leader_info = NodeInfo::new_entry_point(&leader_info.gossip);