Reduce boilerplate code with helper function to create
fullnode/bank/genesis
This commit is contained in:
committed by
sakridge
parent
e4f477cf90
commit
2262f279d5
42
tests/rpc.rs
42
tests/rpc.rs
@ -2,61 +2,25 @@ use bincode::serialize;
|
||||
use reqwest;
|
||||
use reqwest::header::CONTENT_TYPE;
|
||||
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::get_rpc_request_str;
|
||||
use solana::storage_stage::STORAGE_ROTATE_TEST_COUNT;
|
||||
use solana::vote_signer_proxy::VoteSignerProxy;
|
||||
use solana::thin_client::new_fullnode;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_transaction::SystemTransaction;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_rpc_send_tx() {
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
|
||||
let (genesis_block, alice) = GenesisBlock::new(10_000_000);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let (server, leader_data, genesis_block, alice, ledger_path) = new_fullnode("test_rpc_send_tx");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = create_tmp_ledger("rpc_send_tx", &genesis_block);
|
||||
|
||||
let last_id = bank.last_id();
|
||||
let last_id = genesis_block.last_id();
|
||||
let tx = Transaction::system_move(&alice, bob_pubkey, 20, last_id, 0);
|
||||
let serial_tx = serialize(&tx).unwrap();
|
||||
|
||||
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 entry_height = 0;
|
||||
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 client = reqwest::Client::new();
|
||||
let request = json!({
|
||||
"jsonrpc": "2.0",
|
||||
|
Reference in New Issue
Block a user