parent
aeddd8c95a
commit
900933bbcc
|
@ -25,5 +25,6 @@ pub mod nonce;
|
||||||
pub mod offline;
|
pub mod offline;
|
||||||
pub mod stake;
|
pub mod stake;
|
||||||
pub mod storage;
|
pub mod storage;
|
||||||
|
pub mod test_utils;
|
||||||
pub mod validator_info;
|
pub mod validator_info;
|
||||||
pub mod vote;
|
pub mod vote;
|
||||||
|
|
|
@ -456,8 +456,8 @@ pub fn process_create_nonce_account(
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let nonce_account_pubkey = config.signers[nonce_account].pubkey();
|
let nonce_account_pubkey = config.signers[nonce_account].pubkey();
|
||||||
let nonce_account_address = if let Some(seed) = seed.clone() {
|
let nonce_account_address = if let Some(ref seed) = seed {
|
||||||
Pubkey::create_with_seed(&nonce_account_pubkey, &seed, &system_program::id())?
|
Pubkey::create_with_seed(&nonce_account_pubkey, seed, &system_program::id())?
|
||||||
} else {
|
} else {
|
||||||
nonce_account_pubkey
|
nonce_account_pubkey
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
use solana_client::rpc_client::RpcClient;
|
||||||
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
use std::{thread::sleep, time::Duration};
|
||||||
|
|
||||||
|
pub fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
||||||
|
(0..5).for_each(|tries| {
|
||||||
|
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
||||||
|
if balance == expected_balance {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if tries == 4 {
|
||||||
|
assert_eq!(balance, expected_balance);
|
||||||
|
}
|
||||||
|
sleep(Duration::from_millis(500));
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
nonce,
|
nonce,
|
||||||
|
@ -7,6 +8,7 @@ use solana_cli::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
|
use solana_core::contact_info::ContactInfo;
|
||||||
use solana_core::validator::{TestValidator, TestValidatorOptions};
|
use solana_core::validator::{TestValidator, TestValidatorOptions};
|
||||||
use solana_faucet::faucet::run_local_faucet;
|
use solana_faucet::faucet::run_local_faucet;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
|
@ -15,23 +17,11 @@ use solana_sdk::{
|
||||||
signature::{keypair_from_seed, Keypair, Signer},
|
signature::{keypair_from_seed, Keypair, Signer},
|
||||||
system_program,
|
system_program,
|
||||||
};
|
};
|
||||||
use std::{fs::remove_dir_all, sync::mpsc::channel, thread::sleep, time::Duration};
|
use std::{fs::remove_dir_all, sync::mpsc::channel};
|
||||||
|
|
||||||
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
||||||
(0..5).for_each(|tries| {
|
|
||||||
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
|
||||||
if balance == expected_balance {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if tries == 4 {
|
|
||||||
assert_eq!(balance, expected_balance);
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(500));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nonce() {
|
fn test_nonce() {
|
||||||
|
solana_logger::setup();
|
||||||
let TestValidator {
|
let TestValidator {
|
||||||
server,
|
server,
|
||||||
leader_data,
|
leader_data,
|
||||||
|
@ -39,14 +29,8 @@ fn test_nonce() {
|
||||||
ledger_path,
|
ledger_path,
|
||||||
..
|
..
|
||||||
} = TestValidator::run();
|
} = TestValidator::run();
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(alice, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
full_battery_tests(leader_data, alice, None, false);
|
||||||
let json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
|
||||||
|
|
||||||
full_battery_tests(&rpc_client, &faucet_addr, json_rpc_url, None, false);
|
|
||||||
|
|
||||||
server.close().unwrap();
|
server.close().unwrap();
|
||||||
remove_dir_all(ledger_path).unwrap();
|
remove_dir_all(ledger_path).unwrap();
|
||||||
|
@ -61,20 +45,8 @@ fn test_nonce_with_seed() {
|
||||||
ledger_path,
|
ledger_path,
|
||||||
..
|
..
|
||||||
} = TestValidator::run();
|
} = TestValidator::run();
|
||||||
let (sender, receiver) = channel();
|
|
||||||
run_local_faucet(alice, sender, None);
|
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
full_battery_tests(leader_data, alice, Some(String::from("seed")), false);
|
||||||
let json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
|
||||||
|
|
||||||
full_battery_tests(
|
|
||||||
&rpc_client,
|
|
||||||
&faucet_addr,
|
|
||||||
json_rpc_url,
|
|
||||||
Some(String::from("seed")),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
server.close().unwrap();
|
server.close().unwrap();
|
||||||
remove_dir_all(ledger_path).unwrap();
|
remove_dir_all(ledger_path).unwrap();
|
||||||
|
@ -89,6 +61,19 @@ fn test_nonce_with_authority() {
|
||||||
ledger_path,
|
ledger_path,
|
||||||
..
|
..
|
||||||
} = TestValidator::run();
|
} = TestValidator::run();
|
||||||
|
|
||||||
|
full_battery_tests(leader_data, alice, None, true);
|
||||||
|
|
||||||
|
server.close().unwrap();
|
||||||
|
remove_dir_all(ledger_path).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn full_battery_tests(
|
||||||
|
leader_data: ContactInfo,
|
||||||
|
alice: Keypair,
|
||||||
|
seed: Option<String>,
|
||||||
|
use_nonce_authority: bool,
|
||||||
|
) {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
run_local_faucet(alice, sender, None);
|
run_local_faucet(alice, sender, None);
|
||||||
let faucet_addr = receiver.recv().unwrap();
|
let faucet_addr = receiver.recv().unwrap();
|
||||||
|
@ -96,19 +81,6 @@ fn test_nonce_with_authority() {
|
||||||
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
let rpc_client = RpcClient::new_socket(leader_data.rpc);
|
||||||
let json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
let json_rpc_url = format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
|
||||||
|
|
||||||
full_battery_tests(&rpc_client, &faucet_addr, json_rpc_url, None, true);
|
|
||||||
|
|
||||||
server.close().unwrap();
|
|
||||||
remove_dir_all(ledger_path).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn full_battery_tests(
|
|
||||||
rpc_client: &RpcClient,
|
|
||||||
faucet_addr: &std::net::SocketAddr,
|
|
||||||
json_rpc_url: String,
|
|
||||||
seed: Option<String>,
|
|
||||||
use_nonce_authority: bool,
|
|
||||||
) {
|
|
||||||
let mut config_payer = CliConfig::default();
|
let mut config_payer = CliConfig::default();
|
||||||
config_payer.json_rpc_url = json_rpc_url.clone();
|
config_payer.json_rpc_url = json_rpc_url.clone();
|
||||||
let payer = Keypair::new();
|
let payer = Keypair::new();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig, PayCommand},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig, PayCommand},
|
||||||
nonce,
|
nonce,
|
||||||
|
@ -16,20 +17,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
};
|
};
|
||||||
use std::{fs::remove_dir_all, sync::mpsc::channel, thread::sleep, time::Duration};
|
use std::{fs::remove_dir_all, sync::mpsc::channel};
|
||||||
|
|
||||||
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
||||||
(0..5).for_each(|tries| {
|
|
||||||
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
|
||||||
if balance == expected_balance {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if tries == 4 {
|
|
||||||
assert_eq!(balance, expected_balance);
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(500));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cli_timestamp_tx() {
|
fn test_cli_timestamp_tx() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
nonce,
|
nonce,
|
||||||
|
@ -19,20 +20,7 @@ use solana_stake_program::{
|
||||||
stake_instruction::LockupArgs,
|
stake_instruction::LockupArgs,
|
||||||
stake_state::{Lockup, StakeAuthorize, StakeState},
|
stake_state::{Lockup, StakeAuthorize, StakeState},
|
||||||
};
|
};
|
||||||
use std::{fs::remove_dir_all, sync::mpsc::channel, thread::sleep, time::Duration};
|
use std::{fs::remove_dir_all, sync::mpsc::channel};
|
||||||
|
|
||||||
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
||||||
(0..5).for_each(|tries| {
|
|
||||||
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
|
||||||
if balance == expected_balance {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if tries == 4 {
|
|
||||||
assert_eq!(balance, expected_balance);
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(500));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stake_delegation_force() {
|
fn test_stake_delegation_force() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_cli::{
|
use solana_cli::{
|
||||||
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
|
||||||
nonce,
|
nonce,
|
||||||
|
@ -14,20 +15,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
|
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
|
||||||
};
|
};
|
||||||
use std::{fs::remove_dir_all, sync::mpsc::channel, thread::sleep, time::Duration};
|
use std::{fs::remove_dir_all, sync::mpsc::channel};
|
||||||
|
|
||||||
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
||||||
(0..5).for_each(|tries| {
|
|
||||||
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
|
||||||
if balance == expected_balance {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if tries == 4 {
|
|
||||||
assert_eq!(balance, expected_balance);
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(500));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transfer() {
|
fn test_transfer() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use solana_cli::cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig};
|
use solana_cli::cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig};
|
||||||
|
use solana_cli::test_utils::check_balance;
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
use solana_core::validator::TestValidator;
|
use solana_core::validator::TestValidator;
|
||||||
use solana_faucet::faucet::run_local_faucet;
|
use solana_faucet::faucet::run_local_faucet;
|
||||||
|
@ -8,20 +9,7 @@ use solana_sdk::{
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
};
|
};
|
||||||
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
|
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
|
||||||
use std::{fs::remove_dir_all, sync::mpsc::channel, thread::sleep, time::Duration};
|
use std::{fs::remove_dir_all, sync::mpsc::channel};
|
||||||
|
|
||||||
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
|
|
||||||
(0..5).for_each(|tries| {
|
|
||||||
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
|
|
||||||
if balance == expected_balance {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if tries == 4 {
|
|
||||||
assert_eq!(balance, expected_balance);
|
|
||||||
}
|
|
||||||
sleep(Duration::from_millis(500));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_vote_authorize_and_withdraw() {
|
fn test_vote_authorize_and_withdraw() {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use solana_client::{
|
||||||
rpc_client::{get_rpc_request_str, RpcClient},
|
rpc_client::{get_rpc_request_str, RpcClient},
|
||||||
rpc_response::{Response, RpcSignatureResult},
|
rpc_response::{Response, RpcSignatureResult},
|
||||||
};
|
};
|
||||||
|
use solana_core::contact_info::ContactInfo;
|
||||||
use solana_core::{rpc_pubsub::gen_client::Client as PubsubClient, validator::TestValidator};
|
use solana_core::{rpc_pubsub::gen_client::Client as PubsubClient, validator::TestValidator};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
commitment_config::CommitmentConfig, hash::Hash, pubkey::Pubkey, signature::Signer,
|
commitment_config::CommitmentConfig, hash::Hash, pubkey::Pubkey, signature::Signer,
|
||||||
|
@ -26,6 +27,30 @@ use std::{
|
||||||
};
|
};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
macro_rules! json_req {
|
||||||
|
($method: expr, $params: expr) => {{
|
||||||
|
json!({
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"method": $method,
|
||||||
|
"params": $params,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn post_rpc(request: Value, data: &ContactInfo) -> Value {
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
let rpc_addr = data.rpc;
|
||||||
|
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
||||||
|
let response = client
|
||||||
|
.post(&rpc_string)
|
||||||
|
.header(CONTENT_TYPE, "application/json")
|
||||||
|
.body(request.to_string())
|
||||||
|
.send()
|
||||||
|
.unwrap();
|
||||||
|
serde_json::from_str(&response.text().unwrap()).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rpc_send_tx() {
|
fn test_rpc_send_tx() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
@ -39,22 +64,9 @@ fn test_rpc_send_tx() {
|
||||||
} = TestValidator::run();
|
} = TestValidator::run();
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_pubkey = Pubkey::new_rand();
|
||||||
|
|
||||||
let client = reqwest::blocking::Client::new();
|
let req = json_req!("getRecentBlockhash", json!([]));
|
||||||
let request = json!({
|
let json = post_rpc(req, &leader_data);
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "getRecentBlockhash",
|
|
||||||
"params": json!([])
|
|
||||||
});
|
|
||||||
let rpc_addr = leader_data.rpc;
|
|
||||||
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
|
||||||
let response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
|
||||||
let blockhash: Hash = json["result"]["value"]["blockhash"]
|
let blockhash: Hash = json["result"]["value"]["blockhash"]
|
||||||
.as_str()
|
.as_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -65,43 +77,17 @@ fn test_rpc_send_tx() {
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
let serialized_encoded_tx = bs58::encode(serialize(&tx).unwrap()).into_string();
|
let serialized_encoded_tx = bs58::encode(serialize(&tx).unwrap()).into_string();
|
||||||
|
|
||||||
let client = reqwest::blocking::Client::new();
|
let req = json_req!("sendTransaction", json!([serialized_encoded_tx]));
|
||||||
let request = json!({
|
let json: Value = post_rpc(req, &leader_data);
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "sendTransaction",
|
|
||||||
"params": json!([serialized_encoded_tx])
|
|
||||||
});
|
|
||||||
let rpc_addr = leader_data.rpc;
|
|
||||||
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
|
||||||
let response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
|
||||||
let signature = &json["result"];
|
let signature = &json["result"];
|
||||||
|
|
||||||
let mut confirmed_tx = false;
|
let mut confirmed_tx = false;
|
||||||
|
|
||||||
let client = reqwest::blocking::Client::new();
|
let request = json_req!("confirmTransaction", [signature]);
|
||||||
let request = json!({
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "confirmTransaction",
|
|
||||||
"params": [signature],
|
|
||||||
});
|
|
||||||
|
|
||||||
for _ in 0..solana_sdk::clock::DEFAULT_TICKS_PER_SLOT {
|
for _ in 0..solana_sdk::clock::DEFAULT_TICKS_PER_SLOT {
|
||||||
let response = client
|
let json = post_rpc(request.clone(), &leader_data);
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let response_json_text = response.text().unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response_json_text).unwrap();
|
|
||||||
|
|
||||||
if true == json["result"]["value"] {
|
if true == json["result"]["value"] {
|
||||||
confirmed_tx = true;
|
confirmed_tx = true;
|
||||||
|
@ -130,62 +116,23 @@ fn test_rpc_invalid_requests() {
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_pubkey = Pubkey::new_rand();
|
||||||
|
|
||||||
// test invalid get_balance request
|
// test invalid get_balance request
|
||||||
let client = reqwest::blocking::Client::new();
|
let req = json_req!("getBalance", json!(["invalid9999"]));
|
||||||
let request = json!({
|
let json = post_rpc(req, &leader_data);
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "getBalance",
|
|
||||||
"params": json!(["invalid9999"])
|
|
||||||
});
|
|
||||||
let rpc_addr = leader_data.rpc;
|
|
||||||
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
|
||||||
let response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
|
||||||
let the_error = json["error"]["message"].as_str().unwrap();
|
let the_error = json["error"]["message"].as_str().unwrap();
|
||||||
assert_eq!(the_error, "Invalid request");
|
assert_eq!(the_error, "Invalid request");
|
||||||
|
|
||||||
// test invalid get_account_info request
|
// test invalid get_account_info request
|
||||||
let client = reqwest::blocking::Client::new();
|
let req = json_req!("getAccountInfo", json!(["invalid9999"]));
|
||||||
let request = json!({
|
let json = post_rpc(req, &leader_data);
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "getAccountInfo",
|
|
||||||
"params": json!(["invalid9999"])
|
|
||||||
});
|
|
||||||
let rpc_addr = leader_data.rpc;
|
|
||||||
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
|
||||||
let response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
|
||||||
let the_error = json["error"]["message"].as_str().unwrap();
|
let the_error = json["error"]["message"].as_str().unwrap();
|
||||||
assert_eq!(the_error, "Invalid request");
|
assert_eq!(the_error, "Invalid request");
|
||||||
|
|
||||||
// test invalid get_account_info request
|
// test invalid get_account_info request
|
||||||
let client = reqwest::blocking::Client::new();
|
let req = json_req!("getAccountInfo", json!([bob_pubkey.to_string()]));
|
||||||
let request = json!({
|
let json = post_rpc(req, &leader_data);
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 1,
|
|
||||||
"method": "getAccountInfo",
|
|
||||||
"params": json!([bob_pubkey.to_string()])
|
|
||||||
});
|
|
||||||
let rpc_addr = leader_data.rpc;
|
|
||||||
let rpc_string = get_rpc_request_str(rpc_addr, false);
|
|
||||||
let response = client
|
|
||||||
.post(&rpc_string)
|
|
||||||
.header(CONTENT_TYPE, "application/json")
|
|
||||||
.body(request.to_string())
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
let json: Value = serde_json::from_str(&response.text().unwrap()).unwrap();
|
|
||||||
let the_value = &json["result"]["value"];
|
let the_value = &json["result"]["value"];
|
||||||
assert!(the_value.is_null());
|
assert!(the_value.is_null());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue