Fix stakes not being setup correctly
This commit is contained in:
committed by
Michael Vines
parent
e6486b2824
commit
b99e3eafdd
@ -459,8 +459,13 @@ pub fn make_active_set_entries(
|
||||
let voting_keypair = VotingKeypair::new_local(active_keypair);
|
||||
let vote_account_id = voting_keypair.pubkey();
|
||||
|
||||
let new_vote_account_tx =
|
||||
VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *blockhash, 1, 1);
|
||||
let new_vote_account_tx = VoteTransaction::fund_staking_account(
|
||||
active_keypair,
|
||||
vote_account_id,
|
||||
*blockhash,
|
||||
stake.saturating_sub(2),
|
||||
1,
|
||||
);
|
||||
let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]);
|
||||
|
||||
// 3) Create vote entry
|
||||
|
@ -100,13 +100,14 @@ pub fn num_ticks_left_in_slot(bank: &Bank, tick_height: u64) -> u64 {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::staking_utils;
|
||||
use solana_sdk::genesis_block::GenesisBlock;
|
||||
use solana_sdk::genesis_block::{GenesisBlock, BOOTSTRAP_LEADER_TOKENS};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
|
||||
#[test]
|
||||
fn test_leader_schedule_via_bank() {
|
||||
let pubkey = Keypair::new().pubkey();
|
||||
let (genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(2, pubkey, 2);
|
||||
let (genesis_block, _mint_keypair) =
|
||||
GenesisBlock::new_with_leader(BOOTSTRAP_LEADER_TOKENS, pubkey, BOOTSTRAP_LEADER_TOKENS);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
|
||||
let ids_and_stakes: Vec<_> = staking_utils::node_stakes(&bank).into_iter().collect();
|
||||
@ -122,7 +123,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_leader_scheduler1_basic() {
|
||||
let pubkey = Keypair::new().pubkey();
|
||||
let genesis_block = GenesisBlock::new_with_leader(2, pubkey, 2).0;
|
||||
let genesis_block =
|
||||
GenesisBlock::new_with_leader(BOOTSTRAP_LEADER_TOKENS, pubkey, BOOTSTRAP_LEADER_TOKENS)
|
||||
.0;
|
||||
let bank = Bank::new(&genesis_block);
|
||||
assert_eq!(slot_leader(&bank), pubkey);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_local_cluster_start_and_exit() {
|
||||
solana_logger::setup();
|
||||
let network = LocalCluster::new(1, 100, 2);
|
||||
let network = LocalCluster::new(1, 100, 3);
|
||||
drop(network)
|
||||
}
|
||||
}
|
||||
|
@ -158,8 +158,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_bank_staked_nodes_at_epoch() {
|
||||
let pubkey = Keypair::new().pubkey();
|
||||
let bootstrap_tokens = 2;
|
||||
let (genesis_block, _) = GenesisBlock::new_with_leader(2, pubkey, bootstrap_tokens);
|
||||
let bootstrap_tokens = 3;
|
||||
let (genesis_block, _) =
|
||||
GenesisBlock::new_with_leader(bootstrap_tokens, pubkey, bootstrap_tokens);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let bank = new_from_parent(&Arc::new(bank));
|
||||
let ticks_per_offset = bank.stakers_slot_offset() * bank.ticks_per_slot();
|
||||
@ -167,7 +168,7 @@ mod tests {
|
||||
assert_eq!(bank.slot_height(), bank.stakers_slot_offset());
|
||||
|
||||
let mut expected = HashMap::new();
|
||||
expected.insert(pubkey, vec![bootstrap_tokens - 1]);
|
||||
expected.insert(pubkey, vec![bootstrap_tokens - 2]);
|
||||
let bank = new_from_parent(&Arc::new(bank));
|
||||
assert_eq!(
|
||||
node_stakes_at_slot_extractor(&bank, bank.slot_height(), |s, _| s),
|
||||
|
Reference in New Issue
Block a user