Reduce boilerplate code with helper function to create
fullnode/bank/genesis
This commit is contained in:
parent
e4f477cf90
commit
2262f279d5
|
@ -28,7 +28,7 @@ fn bad_arguments() {
|
|||
#[test]
|
||||
fn nominal() {
|
||||
let keypair = Arc::new(Keypair::new());
|
||||
let (_mint, ledger_path, _genesis_entries) =
|
||||
let (_genesis_block, _mint, ledger_path, _genesis_entries) =
|
||||
create_tmp_sample_ledger("test_ledger_tool_nominal", 100, 10, keypair.pubkey(), 50);
|
||||
|
||||
// Basic validation
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
use crate::bank::Bank;
|
||||
use crate::cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo};
|
||||
use crate::fullnode::Fullnode;
|
||||
use crate::genesis_block::GenesisBlock;
|
||||
use crate::gossip_service::GossipService;
|
||||
use crate::packet::PACKET_DATA_SIZE;
|
||||
use crate::result::{Error, Result};
|
||||
|
@ -436,35 +438,23 @@ pub fn retry_get_balance(
|
|||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::bank::Bank;
|
||||
pub fn new_fullnode(
|
||||
ledger_name: &'static str,
|
||||
) -> (Fullnode, NodeInfo, GenesisBlock, Keypair, String) {
|
||||
use crate::cluster_info::Node;
|
||||
use crate::db_ledger::create_tmp_ledger;
|
||||
use crate::fullnode::Fullnode;
|
||||
use crate::genesis_block::GenesisBlock;
|
||||
use crate::leader_scheduler::LeaderScheduler;
|
||||
use crate::storage_stage::STORAGE_ROTATE_TEST_COUNT;
|
||||
use crate::vote_signer_proxy::VoteSignerProxy;
|
||||
use bincode::{deserialize, serialize};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_instruction::SystemInstruction;
|
||||
use solana_sdk::vote_program::VoteProgram;
|
||||
use solana_sdk::vote_transaction::VoteTransaction;
|
||||
use std::fs::remove_dir_all;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
|
||||
#[test]
|
||||
fn test_thin_client() {
|
||||
solana_logger::setup();
|
||||
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 bob_pubkey = Keypair::new().pubkey();
|
||||
let ledger_path = create_tmp_ledger("thin_client", &genesis_block);
|
||||
let ledger_path = create_tmp_ledger(ledger_name, &genesis_block);
|
||||
let entry_height = 0;
|
||||
|
||||
let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::from_bootstrap_leader(
|
||||
|
@ -487,11 +477,31 @@ mod tests {
|
|||
None,
|
||||
STORAGE_ROTATE_TEST_COUNT,
|
||||
);
|
||||
|
||||
(server, leader_data, genesis_block, alice, ledger_path)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::client::mk_client;
|
||||
use bincode::{deserialize, serialize};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_instruction::SystemInstruction;
|
||||
use solana_sdk::vote_program::VoteProgram;
|
||||
use solana_sdk::vote_transaction::VoteTransaction;
|
||||
use std::fs::remove_dir_all;
|
||||
|
||||
#[test]
|
||||
fn test_thin_client() {
|
||||
solana_logger::setup();
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) = new_fullnode("thin_client");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
|
||||
sleep(Duration::from_millis(900));
|
||||
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client = mk_client(&leader_data);
|
||||
|
||||
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
|
||||
let transaction_count = client.transaction_count();
|
||||
assert_eq!(transaction_count, 0);
|
||||
let confirmation = client.get_confirmation_time();
|
||||
|
@ -512,39 +522,15 @@ mod tests {
|
|||
#[ignore]
|
||||
fn test_bad_sig() {
|
||||
solana_logger::setup();
|
||||
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);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = create_tmp_ledger("bad_sig", &genesis_block);
|
||||
|
||||
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,
|
||||
0,
|
||||
&last_id,
|
||||
leader,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
STORAGE_ROTATE_TEST_COUNT,
|
||||
);
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) = new_fullnode("bad_sig");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
|
||||
//TODO: remove this sleep, or add a retry so CI is stable
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
|
||||
let mut client = mk_client(&leader_data);
|
||||
|
||||
let last_id = client.get_last_id();
|
||||
|
||||
let tx = Transaction::system_new(&alice, bob_pubkey, 500, last_id);
|
||||
|
@ -571,39 +557,10 @@ mod tests {
|
|||
#[test]
|
||||
fn test_client_check_signature() {
|
||||
solana_logger::setup();
|
||||
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);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) = new_fullnode("thin_client");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = create_tmp_ledger("client_check_signature", &genesis_block);
|
||||
|
||||
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 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,
|
||||
);
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
|
||||
let mut client = mk_client(&leader_data);
|
||||
let last_id = client.get_last_id();
|
||||
let signature = client.transfer(500, &alice, bob_pubkey, &last_id).unwrap();
|
||||
|
||||
|
@ -616,43 +573,15 @@ mod tests {
|
|||
#[test]
|
||||
fn test_register_vote_account() {
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let (genesis_block, mint_keypair) = GenesisBlock::new(10_000);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = create_tmp_ledger("client_check_signature", &genesis_block);
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) = new_fullnode("thin_client");
|
||||
|
||||
let entry_height = 0;
|
||||
let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::from_bootstrap_leader(
|
||||
leader_data.id,
|
||||
)));
|
||||
bank.leader_scheduler = leader_scheduler;
|
||||
let leader_vote_account_keypair = Arc::new(Keypair::new());
|
||||
let vote_signer = VoteSignerProxy::new_local(&leader_vote_account_keypair);
|
||||
let server = Fullnode::new_with_bank(
|
||||
leader_keypair,
|
||||
Some(Arc::new(vote_signer)),
|
||||
bank,
|
||||
&ledger_path,
|
||||
entry_height,
|
||||
&genesis_block.last_id(),
|
||||
leader,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
STORAGE_ROTATE_TEST_COUNT,
|
||||
);
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
|
||||
let mut client = mk_client(&leader_data);
|
||||
|
||||
// Create the validator account, transfer some tokens to that account
|
||||
let validator_keypair = Keypair::new();
|
||||
let last_id = client.get_last_id();
|
||||
let signature = client
|
||||
.transfer(500, &mint_keypair, validator_keypair.pubkey(), &last_id)
|
||||
.transfer(500, &alice, validator_keypair.pubkey(), &last_id)
|
||||
.unwrap();
|
||||
|
||||
assert!(client.poll_for_signature(&signature).is_ok());
|
||||
|
@ -709,39 +638,10 @@ mod tests {
|
|||
#[test]
|
||||
fn test_zero_balance_after_nonzero() {
|
||||
solana_logger::setup();
|
||||
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);
|
||||
let mut bank = Bank::new(&genesis_block);
|
||||
let (server, leader_data, _genesis_block, alice, ledger_path) = new_fullnode("thin_client");
|
||||
let bob_keypair = Keypair::new();
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = create_tmp_ledger("zero_balance_check", &genesis_block);
|
||||
|
||||
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 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,
|
||||
);
|
||||
sleep(Duration::from_millis(900));
|
||||
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket);
|
||||
let mut client = mk_client(&leader_data);
|
||||
let last_id = client.get_last_id();
|
||||
|
||||
// give bob 500 tokens
|
||||
|
|
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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
use chrono::prelude::*;
|
||||
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_drone::drone::run_local_drone;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
|
@ -17,7 +9,9 @@ use solana_wallet::wallet::{
|
|||
};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[cfg(test)]
|
||||
use solana::thin_client::new_fullnode;
|
||||
|
||||
fn check_balance(expected_balance: u64, client: &RpcClient, params: Value) {
|
||||
let balance = client
|
||||
|
@ -30,36 +24,9 @@ fn check_balance(expected_balance: u64, client: &RpcClient, params: Value) {
|
|||
|
||||
#[test]
|
||||
fn test_wallet_timestamp_tx() {
|
||||
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 (server, leader_data, _genesis_block, alice, ledger_path) =
|
||||
new_fullnode("test_wallet_timestamp_tx");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
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 (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender);
|
||||
|
@ -125,36 +92,9 @@ fn test_wallet_timestamp_tx() {
|
|||
|
||||
#[test]
|
||||
fn test_wallet_witness_tx() {
|
||||
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 (server, leader_data, _genesis_block, alice, ledger_path) =
|
||||
new_fullnode("test_wallet_witness_tx");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let ledger_path = create_tmp_ledger("test_wallet_witness_tx", &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 (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender);
|
||||
|
@ -216,36 +156,9 @@ fn test_wallet_witness_tx() {
|
|||
|
||||
#[test]
|
||||
fn test_wallet_cancel_tx() {
|
||||
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 (server, leader_data, _genesis_block, alice, ledger_path) =
|
||||
new_fullnode("test_wallet_cancel_tx");
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let ledger_path = create_tmp_ledger("test_wallet_cancel_tx", &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 (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender);
|
||||
|
|
|
@ -1,51 +1,16 @@
|
|||
use serde_json::json;
|
||||
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::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[test]
|
||||
fn test_wallet_request_airdrop() {
|
||||
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_request_airdrop");
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice, sender);
|
||||
|
|
Loading…
Reference in New Issue