Boot the Builder pattern from GenesisBlock (#6364)

This commit is contained in:
Greg Fitzgerald
2019-10-15 13:52:44 -06:00
committed by GitHub
parent 41067de5e4
commit ae41c88eb2
12 changed files with 216 additions and 273 deletions

View File

@@ -56,7 +56,7 @@ impl ConfigState for Config {
}
}
pub fn genesis() -> (Pubkey, Account) {
pub fn create_genesis_account() -> (Pubkey, Account) {
(id(), create_config_account(vec![], &Config::default(), 100))
}
@@ -83,7 +83,7 @@ mod tests {
from_keyed_account(&KeyedAccount::new(&Pubkey::default(), false, &mut account)),
Err(InstructionError::InvalidArgument)
);
let (pubkey, mut account) = genesis();
let (pubkey, mut account) = create_genesis_account();
assert_eq!(
from_keyed_account(&KeyedAccount::new(&pubkey, false, &mut account)),
Ok(Config::default())

View File

@@ -1,3 +1,7 @@
use crate::config::create_genesis_account;
use crate::rewards_pools::create_rewards_accounts;
use solana_sdk::genesis_block::GenesisBlock;
pub mod config;
pub mod rewards_pools;
pub mod stake_instruction;
@@ -13,11 +17,11 @@ solana_sdk::solana_name_id!(
"Stake11111111111111111111111111111111111111"
);
use solana_sdk::genesis_block::Builder;
pub fn genesis(mut builder: Builder) -> Builder {
for (pubkey, account) in crate::rewards_pools::genesis().iter() {
builder = builder.rewards_pool(*pubkey, account.clone());
pub fn add_genesis_accounts(genesis_block: &mut GenesisBlock) {
for (pubkey, account) in create_rewards_accounts() {
genesis_block.add_rewards_pool(pubkey, account);
}
builder.accounts(&[crate::config::genesis()])
let (pubkey, account) = create_genesis_account();
genesis_block.add_account(pubkey, account);
}

View File

@@ -31,7 +31,7 @@ pub fn random_id() -> Pubkey {
Pubkey::new(id.as_ref())
}
pub fn genesis() -> Vec<(Pubkey, Account)> {
pub fn create_rewards_accounts() -> Vec<(Pubkey, Account)> {
let mut accounts = Vec::with_capacity(NUM_REWARDS_POOLS);
let mut pubkey = id();
@@ -51,7 +51,7 @@ mod tests {
#[test]
fn test() {
let accounts = genesis();
let accounts = create_rewards_accounts();
for _i in 0..NUM_REWARDS_POOLS {
let id = random_id();