Add RPC port option to fullnode
This commit is contained in:
parent
9228fe11c9
commit
e3b3701e13
|
@ -338,6 +338,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
|
||||
let mut addr: SocketAddr = "0.0.0.0:9900".parse().expect("bind to drone socket");
|
||||
|
|
|
@ -144,6 +144,7 @@ impl Fullnode {
|
|||
ledger_path,
|
||||
sigverify_disabled,
|
||||
leader_rotation_interval,
|
||||
None,
|
||||
);
|
||||
|
||||
match leader_addr {
|
||||
|
@ -224,6 +225,7 @@ impl Fullnode {
|
|||
ledger_path: &str,
|
||||
sigverify_disabled: bool,
|
||||
leader_rotation_interval: Option<u64>,
|
||||
rpc_port: Option<u16>,
|
||||
) -> Self {
|
||||
if leader_info.is_none() {
|
||||
node.info.leader_id = node.info.id;
|
||||
|
@ -246,7 +248,11 @@ impl Fullnode {
|
|||
// TODO: this code assumes this node is the leader
|
||||
let mut drone_addr = node.info.contact_info.tpu;
|
||||
drone_addr.set_port(DRONE_PORT);
|
||||
let rpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::from(0)), RPC_PORT);
|
||||
let rpc_addr = if let Some(port) = rpc_port {
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::from(0)), port)
|
||||
} else {
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::from(0)), RPC_PORT)
|
||||
};
|
||||
let rpc_service = JsonRpcService::new(
|
||||
&bank,
|
||||
node.info.contact_info.tpu,
|
||||
|
@ -527,6 +533,7 @@ mod tests {
|
|||
&validator_ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
v.close().unwrap();
|
||||
remove_dir_all(validator_ledger_path).unwrap();
|
||||
|
@ -553,6 +560,7 @@ mod tests {
|
|||
&validator_ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
)
|
||||
}).collect();
|
||||
|
||||
|
|
|
@ -465,6 +465,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
sleep(Duration::from_millis(900));
|
||||
|
||||
|
@ -511,6 +512,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
//TODO: remove this sleep, or add a retry so CI is stable
|
||||
sleep(Duration::from_millis(300));
|
||||
|
@ -570,6 +572,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
|
@ -630,6 +633,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(0),
|
||||
);
|
||||
sleep(Duration::from_millis(900));
|
||||
|
||||
|
|
|
@ -358,9 +358,7 @@ mod tests {
|
|||
use fullnode::Fullnode;
|
||||
use ledger::LedgerWriter;
|
||||
use mint::Mint;
|
||||
use rpc::RPC_PORT;
|
||||
use signature::{read_keypair, read_pkcs8, Keypair, KeypairUtil};
|
||||
use std::net::UdpSocket;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
fn tmp_ledger(name: &str, mint: &Mint) -> String {
|
||||
|
@ -478,6 +476,7 @@ mod tests {
|
|||
let ledger_path = tmp_ledger("thin_client", &alice);
|
||||
|
||||
let mut config = WalletConfig::default();
|
||||
let rpc_port = 12345; // Needs to be distinct known number to not conflict with following test
|
||||
|
||||
let _server = Fullnode::new_with_bank(
|
||||
leader_keypair,
|
||||
|
@ -489,6 +488,7 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(rpc_port),
|
||||
);
|
||||
sleep(Duration::from_millis(200));
|
||||
|
||||
|
@ -498,7 +498,7 @@ mod tests {
|
|||
config.leader = leader_data1;
|
||||
|
||||
let mut rpc_addr = leader_data.contact_info.ncp;
|
||||
rpc_addr.set_port(RPC_PORT);
|
||||
rpc_addr.set_port(rpc_port);
|
||||
config.rpc_addr = rpc_addr;
|
||||
|
||||
let tokens = 50;
|
||||
|
@ -549,6 +549,8 @@ mod tests {
|
|||
let leader_data = leader.info.clone();
|
||||
let ledger_path = tmp_ledger("thin_client", &alice);
|
||||
|
||||
let rpc_port = 11111; // Needs to be distinct known number to not conflict with previous test
|
||||
|
||||
let _server = Fullnode::new_with_bank(
|
||||
leader_keypair,
|
||||
bank,
|
||||
|
@ -559,18 +561,16 @@ mod tests {
|
|||
&ledger_path,
|
||||
false,
|
||||
None,
|
||||
Some(rpc_port),
|
||||
);
|
||||
sleep(Duration::from_millis(200));
|
||||
|
||||
let requests_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
run_local_drone(alice.keypair(), leader_data.contact_info.ncp, sender);
|
||||
let drone_addr = receiver.recv().unwrap();
|
||||
|
||||
let mut rpc_addr = leader_data.contact_info.ncp;
|
||||
rpc_addr.set_port(RPC_PORT);
|
||||
rpc_addr.set_port(rpc_port);
|
||||
|
||||
let signature = request_airdrop(&drone_addr, &bob_pubkey, 50);
|
||||
assert!(signature.is_ok());
|
||||
|
@ -597,33 +597,4 @@ mod tests {
|
|||
fs::remove_file(outfile).unwrap();
|
||||
assert!(!Path::new(outfile).exists());
|
||||
}
|
||||
#[test]
|
||||
fn test_make_rpc_request() {
|
||||
// let leader_keypair = Keypair::new();
|
||||
// let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
//
|
||||
// let alice = Mint::new(10_000_000);
|
||||
// let bank = Bank::new(&alice);
|
||||
// let bob_pubkey = Keypair::new().pubkey();
|
||||
// let leader_data = leader.info.clone();
|
||||
// let leader_data1 = leader.info.clone();
|
||||
// let ledger_path = tmp_ledger("thin_client", &alice);
|
||||
//
|
||||
// let mut config = WalletConfig::default();
|
||||
//
|
||||
// let _server = Fullnode::new_with_bank(
|
||||
// leader_keypair,
|
||||
// bank,
|
||||
// 0,
|
||||
// &[],
|
||||
// leader,
|
||||
// None,
|
||||
// &ledger_path,
|
||||
// false,
|
||||
// None,
|
||||
// );
|
||||
// sleep(Duration::from_millis(200));
|
||||
|
||||
assert!(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue