Reduce boilerplate code with helper function to create
fullnode/bank/genesis
This commit is contained in:
committed by
sakridge
parent
e4f477cf90
commit
2262f279d5
@ -1,22 +1,13 @@
|
||||
use serde_json::{json, Value};
|
||||
use solana::bank::Bank;
|
||||
use solana::cluster_info::Node;
|
||||
use solana::db_ledger::create_tmp_ledger;
|
||||
use solana::fullnode::Fullnode;
|
||||
use solana::genesis_block::GenesisBlock;
|
||||
use solana::leader_scheduler::LeaderScheduler;
|
||||
use solana::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler};
|
||||
use solana::storage_stage::STORAGE_ROTATE_TEST_COUNT;
|
||||
use solana::vote_signer_proxy::VoteSignerProxy;
|
||||
use solana::thin_client::new_fullnode;
|
||||
use solana_drone::drone::run_local_drone;
|
||||
use solana_sdk::bpf_loader;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig};
|
||||
use std::fs::{remove_dir_all, File};
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[test]
|
||||
fn test_wallet_deploy_program() {
|
||||
@ -26,35 +17,8 @@ fn test_wallet_deploy_program() {
|
||||
pathbuf.push("noop");
|
||||
pathbuf.set_extension("so");
|
||||
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let leader_data = leader.info.clone();
|
||||
|
||||
let (genesis_block, alice) = GenesisBlock::new(10_000);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let ledger_path = create_tmp_ledger("thin_client", &genesis_block);
|
||||
let entry_height = 0;
|
||||
|
||||
let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::from_bootstrap_leader(
|
||||
leader_data.id,
|
||||
)));
|
||||
bank.leader_scheduler = leader_scheduler;
|
||||
let vote_account_keypair = Arc::new(Keypair::new());
|
||||
let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
|
||||
let last_id = bank.last_id();
|
||||
let server = Fullnode::new_with_bank(
|
||||
leader_keypair,
|
||||
Some(Arc::new(vote_signer)),
|
||||
bank,
|
||||
&ledger_path,
|
||||
entry_height,
|
||||
&last_id,
|
||||
leader,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
STORAGE_ROTATE_TEST_COUNT,
|
||||
);
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) =
|
||||
new_fullnode("test_wallet_deploy_program");
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender);
|
||||
|
Reference in New Issue
Block a user