create_tmp_sample_ledger() need not return the genesis block
This commit is contained in:
parent
494b143453
commit
9e9c82869a
|
@ -32,7 +32,7 @@ fn bad_arguments() {
|
|||
#[test]
|
||||
fn nominal() {
|
||||
let keypair = Arc::new(Keypair::new());
|
||||
let (_, _, ledger_path, _, _) =
|
||||
let (_, ledger_path, _, _) =
|
||||
create_tmp_sample_ledger("test_ledger_tool_nominal", 100, 10, keypair.pubkey(), 50);
|
||||
|
||||
// Basic validation
|
||||
|
|
|
@ -885,23 +885,23 @@ pub fn create_tmp_sample_ledger(
|
|||
num_extra_ticks: u64,
|
||||
bootstrap_leader_id: Pubkey,
|
||||
bootstrap_leader_tokens: u64,
|
||||
) -> (GenesisBlock, Keypair, String, u64, Hash) {
|
||||
) -> (Keypair, String, u64, Hash) {
|
||||
let (genesis_block, mint_keypair) =
|
||||
GenesisBlock::new_with_leader(num_tokens, bootstrap_leader_id, bootstrap_leader_tokens);
|
||||
let path = get_tmp_ledger_path(name);
|
||||
let (mut entry_height, mut last_id) = create_empty_ledger(&path, &genesis_block).unwrap();
|
||||
let ledger_path = get_tmp_ledger_path(name);
|
||||
let (mut entry_height, mut last_id) = create_new_ledger(&ledger_path, &genesis_block).unwrap();
|
||||
|
||||
if num_extra_ticks > 0 {
|
||||
let entries = crate::entry::create_ticks(num_extra_ticks, last_id);
|
||||
|
||||
let db_ledger = DbLedger::open(&path).unwrap();
|
||||
let db_ledger = DbLedger::open(&ledger_path).unwrap();
|
||||
db_ledger
|
||||
.write_entries(DEFAULT_SLOT_HEIGHT, entry_height, &entries)
|
||||
.unwrap();
|
||||
entry_height += entries.len() as u64;
|
||||
last_id = entries.last().unwrap().id
|
||||
}
|
||||
(genesis_block, mint_keypair, path, entry_height, last_id)
|
||||
(mint_keypair, ledger_path, entry_height, last_id)
|
||||
}
|
||||
|
||||
pub fn tmp_copy_ledger(from: &str, name: &str) -> String {
|
||||
|
|
|
@ -463,7 +463,7 @@ mod tests {
|
|||
|
||||
let validator_keypair = Keypair::new();
|
||||
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
|
||||
let (_, _, validator_ledger_path, _, _) =
|
||||
let (_, validator_ledger_path, _, _) =
|
||||
create_tmp_sample_ledger("validator_exit", 10_000, 0, leader_keypair.pubkey(), 1000);
|
||||
|
||||
let validator = Fullnode::new(
|
||||
|
@ -489,7 +489,7 @@ mod tests {
|
|||
.map(|i| {
|
||||
let validator_keypair = Keypair::new();
|
||||
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
|
||||
let (_, _, validator_ledger_path, _, _) = create_tmp_sample_ledger(
|
||||
let (_, validator_ledger_path, _, _) = create_tmp_sample_ledger(
|
||||
&format!("validator_parallel_exit_{}", i),
|
||||
10_000,
|
||||
0,
|
||||
|
@ -532,19 +532,14 @@ mod tests {
|
|||
let bootstrap_leader_info = bootstrap_leader_node.info.clone();
|
||||
|
||||
// Make a mint and a genesis entries for leader ledger
|
||||
let (
|
||||
_genesis_block,
|
||||
_mint_keypair,
|
||||
bootstrap_leader_ledger_path,
|
||||
_genesis_entry_height,
|
||||
_last_id,
|
||||
) = create_tmp_sample_ledger(
|
||||
"test_leader_to_leader_transition",
|
||||
10_000,
|
||||
1,
|
||||
bootstrap_leader_keypair.pubkey(),
|
||||
500,
|
||||
);
|
||||
let (_mint_keypair, bootstrap_leader_ledger_path, _genesis_entry_height, _last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_leader_to_leader_transition",
|
||||
10_000,
|
||||
1,
|
||||
bootstrap_leader_keypair.pubkey(),
|
||||
500,
|
||||
);
|
||||
|
||||
// Create the common leader scheduling configuration
|
||||
let num_slots_per_epoch = 3;
|
||||
|
@ -604,19 +599,14 @@ mod tests {
|
|||
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
|
||||
|
||||
// Make a common mint and a genesis entry for both leader + validator's ledgers
|
||||
let (
|
||||
_genesis_block,
|
||||
mint_keypair,
|
||||
bootstrap_leader_ledger_path,
|
||||
genesis_entry_height,
|
||||
last_id,
|
||||
) = create_tmp_sample_ledger(
|
||||
"test_wrong_role_transition",
|
||||
10_000,
|
||||
0,
|
||||
bootstrap_leader_keypair.pubkey(),
|
||||
500,
|
||||
);
|
||||
let (mint_keypair, bootstrap_leader_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_wrong_role_transition",
|
||||
10_000,
|
||||
0,
|
||||
bootstrap_leader_keypair.pubkey(),
|
||||
500,
|
||||
);
|
||||
|
||||
// Write the entries to the ledger that will cause leader rotation
|
||||
// after the bootstrap height
|
||||
|
@ -701,7 +691,7 @@ mod tests {
|
|||
let leader_id = leader_node.info.id;
|
||||
|
||||
// Create validator identity
|
||||
let (_genesis_block, mint_keypair, validator_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, validator_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_validator_to_leader_transition",
|
||||
10_000,
|
||||
|
|
|
@ -328,7 +328,7 @@ mod test {
|
|||
|
||||
// Create a ledger
|
||||
let num_ending_ticks = 3;
|
||||
let (_, mint_keypair, my_ledger_path, genesis_entry_height, mut last_id) =
|
||||
let (mint_keypair, my_ledger_path, genesis_entry_height, mut last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_replay_stage_leader_rotation_exit",
|
||||
10_000,
|
||||
|
@ -461,7 +461,7 @@ mod test {
|
|||
let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::default()));
|
||||
|
||||
let num_ending_ticks = 1;
|
||||
let (_, _, my_ledger_path, _, _) = create_tmp_sample_ledger(
|
||||
let (_, my_ledger_path, _, _) = create_tmp_sample_ledger(
|
||||
"test_vote_error_replay_stage_correctness",
|
||||
10_000,
|
||||
num_ending_ticks,
|
||||
|
@ -530,7 +530,7 @@ mod test {
|
|||
let leader_id = Keypair::new().pubkey();
|
||||
|
||||
// Create the ledger
|
||||
let (_genesis_block, mint_keypair, my_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, my_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_vote_error_replay_stage_leader_rotation",
|
||||
10_000,
|
||||
|
|
|
@ -498,14 +498,13 @@ mod tests {
|
|||
let keypair = Arc::new(Keypair::new());
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let (_genesis_block, _mint, ledger_path, genesis_entry_height, _last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"storage_stage_process_entries",
|
||||
1000,
|
||||
1,
|
||||
Keypair::new().pubkey(),
|
||||
1,
|
||||
);
|
||||
let (_mint, ledger_path, genesis_entry_height, _last_id) = create_tmp_sample_ledger(
|
||||
"storage_stage_process_entries",
|
||||
1000,
|
||||
1,
|
||||
Keypair::new().pubkey(),
|
||||
1,
|
||||
);
|
||||
|
||||
let entries = make_tiny_test_entries(64);
|
||||
let db_ledger = DbLedger::open(&ledger_path).unwrap();
|
||||
|
@ -567,14 +566,13 @@ mod tests {
|
|||
let keypair = Arc::new(Keypair::new());
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let (_genesis_block, _mint, ledger_path, genesis_entry_height, _last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"storage_stage_process_entries",
|
||||
1000,
|
||||
1,
|
||||
Keypair::new().pubkey(),
|
||||
1,
|
||||
);
|
||||
let (_mint, ledger_path, genesis_entry_height, _last_id) = create_tmp_sample_ledger(
|
||||
"storage_stage_process_entries",
|
||||
1000,
|
||||
1,
|
||||
Keypair::new().pubkey(),
|
||||
1,
|
||||
);
|
||||
|
||||
let entries = make_tiny_test_entries(128);
|
||||
let db_ledger = DbLedger::open(&ledger_path).unwrap();
|
||||
|
|
|
@ -447,7 +447,7 @@ pub fn new_fullnode(ledger_name: &'static str) -> (Fullnode, NodeInfo, Keypair,
|
|||
let node = Node::new_localhost_with_pubkey(node_keypair.pubkey());
|
||||
let node_info = node.info.clone();
|
||||
|
||||
let (_genesis_block, mint_keypair, ledger_path, _, _) =
|
||||
let (mint_keypair, ledger_path, _, _) =
|
||||
create_tmp_sample_ledger(ledger_name, 10_000, 0, node_info.id, 42);
|
||||
|
||||
let leader_scheduler = LeaderScheduler::from_bootstrap_leader(node_info.id);
|
||||
|
|
|
@ -135,7 +135,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let mut ledger_paths = Vec::new();
|
||||
|
||||
let (genesis_block, alice, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
let (alice, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger("multi_node_ledger_window", 10_000, 0, leader_data.id, 500);
|
||||
ledger_paths.push(leader_ledger_path.clone());
|
||||
|
||||
|
@ -236,14 +236,13 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let mut ledger_paths = Vec::new();
|
||||
|
||||
let (_genesis_block, alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"multi_node_validator_catchup_from_zero",
|
||||
10_000,
|
||||
0,
|
||||
leader_data.id,
|
||||
500,
|
||||
);
|
||||
let (alice, genesis_ledger_path, _last_entry_height, _last_entry_id) = create_tmp_sample_ledger(
|
||||
"multi_node_validator_catchup_from_zero",
|
||||
10_000,
|
||||
0,
|
||||
leader_data.id,
|
||||
500,
|
||||
);
|
||||
ledger_paths.push(genesis_ledger_path.clone());
|
||||
|
||||
let zero_ledger_path = tmp_copy_ledger(
|
||||
|
@ -434,7 +433,7 @@ fn test_multi_node_basic() {
|
|||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let mut ledger_paths = Vec::new();
|
||||
|
||||
let (_genesis_block, alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
let (alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger("multi_node_basic", 10_000, 0, leader_data.id, 500);
|
||||
ledger_paths.push(genesis_ledger_path.clone());
|
||||
|
||||
|
@ -541,7 +540,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
|
|||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let mut ledger_paths = Vec::new();
|
||||
|
||||
let (_genesis_block, alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
let (alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger("boot_validator_from_file", 100_000, 0, leader_pubkey, 1000);
|
||||
ledger_paths.push(genesis_ledger_path.clone());
|
||||
|
||||
|
@ -629,14 +628,13 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
|
|||
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let initial_leader_balance = 500;
|
||||
let (_genesis_block, alice, ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"leader_restart_validator_start_from_old_ledger",
|
||||
100_000 + 500 * solana::window_service::MAX_REPAIR_BACKOFF as u64,
|
||||
0,
|
||||
leader_keypair.pubkey(),
|
||||
initial_leader_balance,
|
||||
);
|
||||
let (alice, ledger_path, _last_entry_height, _last_entry_id) = create_tmp_sample_ledger(
|
||||
"leader_restart_validator_start_from_old_ledger",
|
||||
100_000 + 500 * solana::window_service::MAX_REPAIR_BACKOFF as u64,
|
||||
0,
|
||||
leader_keypair.pubkey(),
|
||||
initial_leader_balance,
|
||||
);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
|
||||
let signer_proxy = Arc::new(VoteSignerProxy::new_local(&leader_keypair));
|
||||
|
@ -740,14 +738,13 @@ fn test_multi_node_dynamic_network() {
|
|||
let leader_pubkey = leader_keypair.pubkey().clone();
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let (_genesis_block, alice, genesis_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"multi_node_dynamic_network",
|
||||
10_000_000,
|
||||
0,
|
||||
leader_pubkey,
|
||||
500,
|
||||
);
|
||||
let (alice, genesis_ledger_path, _last_entry_height, _last_entry_id) = create_tmp_sample_ledger(
|
||||
"multi_node_dynamic_network",
|
||||
10_000_000,
|
||||
0,
|
||||
leader_pubkey,
|
||||
500,
|
||||
);
|
||||
|
||||
let mut ledger_paths = Vec::new();
|
||||
ledger_paths.push(genesis_ledger_path.clone());
|
||||
|
@ -975,7 +972,7 @@ fn test_leader_to_validator_transition() {
|
|||
// Initialize the leader ledger. Make a mint and a genesis entry
|
||||
// in the leader ledger
|
||||
let num_ending_ticks = 1;
|
||||
let (_genesis_block, mint_keypair, leader_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, leader_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_leader_to_validator_transition",
|
||||
10_000,
|
||||
|
@ -1115,7 +1112,7 @@ fn test_leader_validator_basic() {
|
|||
|
||||
// Make a common mint and a genesis entry for both leader + validator ledgers
|
||||
let num_ending_ticks = 1;
|
||||
let (_genesis_block, mint_keypair, leader_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, leader_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_leader_validator_basic",
|
||||
10_000,
|
||||
|
@ -1298,7 +1295,7 @@ fn test_dropped_handoff_recovery() {
|
|||
|
||||
// Make a common mint and a genesis entry for both leader + validator's ledgers
|
||||
let num_ending_ticks = 1;
|
||||
let (_genesis_block, mint_keypair, genesis_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, genesis_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_dropped_handoff_recovery",
|
||||
10_000,
|
||||
|
@ -1459,7 +1456,7 @@ fn test_full_leader_validator_network() {
|
|||
|
||||
// Make a common mint and a genesis entry for both leader + validator's ledgers
|
||||
let num_ending_ticks = 1;
|
||||
let (_genesis_block, mint_keypair, bootstrap_leader_ledger_path, genesis_entry_height, last_id) =
|
||||
let (mint_keypair, bootstrap_leader_ledger_path, genesis_entry_height, last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_full_leader_validator_network",
|
||||
10_000,
|
||||
|
@ -1690,19 +1687,14 @@ fn test_broadcast_last_tick() {
|
|||
let bootstrap_leader_info = bootstrap_leader_node.info.clone();
|
||||
|
||||
// Create leader ledger
|
||||
let (
|
||||
_genesis_block,
|
||||
_mint_keypair,
|
||||
bootstrap_leader_ledger_path,
|
||||
genesis_entry_height,
|
||||
_last_id,
|
||||
) = create_tmp_sample_ledger(
|
||||
"test_broadcast_last_tick",
|
||||
10_000,
|
||||
1,
|
||||
bootstrap_leader_info.id,
|
||||
500,
|
||||
);
|
||||
let (_mint_keypair, bootstrap_leader_ledger_path, genesis_entry_height, _last_id) =
|
||||
create_tmp_sample_ledger(
|
||||
"test_broadcast_last_tick",
|
||||
10_000,
|
||||
1,
|
||||
bootstrap_leader_info.id,
|
||||
500,
|
||||
);
|
||||
|
||||
let genesis_ledger_len = genesis_entry_height;
|
||||
debug!("genesis_ledger_len: {}", genesis_ledger_len);
|
||||
|
|
|
@ -40,7 +40,7 @@ fn test_replicator_startup() {
|
|||
let leader_info = leader_node.info.clone();
|
||||
|
||||
let leader_ledger_path = "replicator_test_leader_ledger";
|
||||
let (_genesis_block, mint_keypair, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
let (mint_keypair, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger(leader_ledger_path, 1_000_000_000, 0, leader_info.id, 1);
|
||||
|
||||
let validator_ledger_path =
|
||||
|
@ -267,7 +267,7 @@ fn test_replicator_startup_ledger_hang() {
|
|||
let leader_info = leader_node.info.clone();
|
||||
|
||||
let leader_ledger_path = "replicator_test_leader_ledger";
|
||||
let (_genesis_block, _mint_keypair, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
let (_mint_keypair, leader_ledger_path, _last_entry_height, _last_entry_id) =
|
||||
create_tmp_sample_ledger(leader_ledger_path, 100, 0, leader_info.id, 1);
|
||||
|
||||
let validator_ledger_path =
|
||||
|
|
Loading…
Reference in New Issue