|
|
|
@@ -1558,12 +1558,12 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
"Invalid param: not a v2.0 Token account".to_string(),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
let token_account = TokenAccount::unpack(&account.data()).map_err(|_| {
|
|
|
|
|
let token_account = TokenAccount::unpack(account.data()).map_err(|_| {
|
|
|
|
|
Error::invalid_params("Invalid param: not a v2.0 Token account".to_string())
|
|
|
|
|
})?;
|
|
|
|
|
let mint = &Pubkey::from_str(&token_account.mint.to_string())
|
|
|
|
|
.expect("Token account mint should be convertible to Pubkey");
|
|
|
|
|
let (_, decimals) = get_mint_owner_and_decimals(&bank, &mint)?;
|
|
|
|
|
let (_, decimals) = get_mint_owner_and_decimals(&bank, mint)?;
|
|
|
|
|
let balance = token_amount_to_ui_amount(token_account.amount, decimals);
|
|
|
|
|
Ok(new_response(&bank, balance))
|
|
|
|
|
}
|
|
|
|
@@ -1582,7 +1582,7 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
"Invalid param: not a v2.0 Token mint".to_string(),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
let mint = Mint::unpack(&mint_account.data()).map_err(|_| {
|
|
|
|
|
let mint = Mint::unpack(mint_account.data()).map_err(|_| {
|
|
|
|
|
Error::invalid_params("Invalid param: mint could not be unpacked".to_string())
|
|
|
|
|
})?;
|
|
|
|
|
|
|
|
|
@@ -1603,10 +1603,10 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
let mut token_balances: Vec<RpcTokenAccountBalance> = self
|
|
|
|
|
.get_filtered_spl_token_accounts_by_mint(&bank, &mint, vec![])?
|
|
|
|
|
.get_filtered_spl_token_accounts_by_mint(&bank, mint, vec![])?
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(|(address, account)| {
|
|
|
|
|
let amount = TokenAccount::unpack(&account.data())
|
|
|
|
|
let amount = TokenAccount::unpack(account.data())
|
|
|
|
|
.map(|account| account.amount)
|
|
|
|
|
.unwrap_or(0);
|
|
|
|
|
let amount = token_amount_to_ui_amount(amount, decimals);
|
|
|
|
@@ -1742,7 +1742,7 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
let filter_closure = |account: &AccountSharedData| {
|
|
|
|
|
filters.iter().all(|filter_type| match filter_type {
|
|
|
|
|
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
if self
|
|
|
|
@@ -1811,7 +1811,7 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
account.owner() == &spl_token_id_v2_0()
|
|
|
|
|
&& filters.iter().all(|filter_type| match filter_type {
|
|
|
|
|
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
@@ -1858,7 +1858,7 @@ impl JsonRpcRequestProcessor {
|
|
|
|
|
account.owner() == &spl_token_id_v2_0()
|
|
|
|
|
&& filters.iter().all(|filter_type| match filter_type {
|
|
|
|
|
RpcFilterType::DataSize(size) => account.data().len() as u64 == *size,
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(&account.data()),
|
|
|
|
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
|
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
@@ -2043,7 +2043,7 @@ fn get_token_program_id_and_mint(
|
|
|
|
|
) -> Result<(Pubkey, Option<Pubkey>)> {
|
|
|
|
|
match token_account_filter {
|
|
|
|
|
TokenAccountsFilter::Mint(mint) => {
|
|
|
|
|
let (mint_owner, _) = get_mint_owner_and_decimals(&bank, &mint)?;
|
|
|
|
|
let (mint_owner, _) = get_mint_owner_and_decimals(bank, &mint)?;
|
|
|
|
|
if mint_owner != spl_token_id_v2_0() {
|
|
|
|
|
return Err(Error::invalid_params(
|
|
|
|
|
"Invalid param: not a v2.0 Token mint".to_string(),
|
|
|
|
@@ -2951,7 +2951,7 @@ pub mod rpc_full {
|
|
|
|
|
let durable_nonce_info = solana_sdk::transaction::uses_durable_nonce(&transaction)
|
|
|
|
|
.and_then(|nonce_ix| {
|
|
|
|
|
solana_sdk::transaction::get_nonce_pubkey_from_instruction(
|
|
|
|
|
&nonce_ix,
|
|
|
|
|
nonce_ix,
|
|
|
|
|
&transaction,
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
@@ -3077,7 +3077,7 @@ pub mod rpc_full {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Ok(new_response(
|
|
|
|
|
&bank,
|
|
|
|
|
bank,
|
|
|
|
|
RpcSimulateTransactionResult {
|
|
|
|
|
err: result.err(),
|
|
|
|
|
logs: Some(logs),
|
|
|
|
@@ -3798,17 +3798,17 @@ pub fn create_test_transactions_and_populate_blockstore(
|
|
|
|
|
// Generate transactions for processing
|
|
|
|
|
// Successful transaction
|
|
|
|
|
let success_tx =
|
|
|
|
|
solana_sdk::system_transaction::transfer(&mint_keypair, &keypair1.pubkey(), 2, blockhash);
|
|
|
|
|
solana_sdk::system_transaction::transfer(mint_keypair, &keypair1.pubkey(), 2, blockhash);
|
|
|
|
|
let success_signature = success_tx.signatures[0];
|
|
|
|
|
let entry_1 = solana_ledger::entry::next_entry(&blockhash, 1, vec![success_tx]);
|
|
|
|
|
// Failed transaction, InstructionError
|
|
|
|
|
let ix_error_tx =
|
|
|
|
|
solana_sdk::system_transaction::transfer(&keypair2, &keypair3.pubkey(), 10, blockhash);
|
|
|
|
|
solana_sdk::system_transaction::transfer(keypair2, &keypair3.pubkey(), 10, blockhash);
|
|
|
|
|
let ix_error_signature = ix_error_tx.signatures[0];
|
|
|
|
|
let entry_2 = solana_ledger::entry::next_entry(&entry_1.hash, 1, vec![ix_error_tx]);
|
|
|
|
|
// Failed transaction
|
|
|
|
|
let fail_tx = solana_sdk::system_transaction::transfer(
|
|
|
|
|
&mint_keypair,
|
|
|
|
|
mint_keypair,
|
|
|
|
|
&keypair2.pubkey(),
|
|
|
|
|
2,
|
|
|
|
|
Hash::default(),
|
|
|
|
@@ -4181,7 +4181,7 @@ pub mod tests {
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getClusterNodes"}"#;
|
|
|
|
|
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -4203,7 +4203,7 @@ pub mod tests {
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getRecentPerformanceSamples"}"#;
|
|
|
|
|
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -4233,7 +4233,7 @@ pub mod tests {
|
|
|
|
|
let req =
|
|
|
|
|
r#"{"jsonrpc":"2.0","id":1,"method":"getRecentPerformanceSamples","params":[10000]}"#;
|
|
|
|
|
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -4262,7 +4262,7 @@ pub mod tests {
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSlotLeader"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, leader_pubkey);
|
|
|
|
|
let expected: Response =
|
|
|
|
|
serde_json::from_str(&expected).expect("expected response deserialization");
|
|
|
|
@@ -4292,10 +4292,10 @@ pub mod tests {
|
|
|
|
|
io.extend_with(rpc_minimal::MinimalImpl.to_delegate());
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getTransactionCount"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = r#"{"jsonrpc":"2.0","result":4,"id":1}"#;
|
|
|
|
|
let expected: Response =
|
|
|
|
|
serde_json::from_str(&expected).expect("expected response deserialization");
|
|
|
|
|
serde_json::from_str(expected).expect("expected response deserialization");
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
assert_eq!(expected, result);
|
|
|
|
@@ -4307,10 +4307,10 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"minimumLedgerSlot"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = r#"{"jsonrpc":"2.0","result":0,"id":1}"#;
|
|
|
|
|
let expected: Response =
|
|
|
|
|
serde_json::from_str(&expected).expect("expected response deserialization");
|
|
|
|
|
serde_json::from_str(expected).expect("expected response deserialization");
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
assert_eq!(expected, result);
|
|
|
|
@@ -4321,7 +4321,7 @@ pub mod tests {
|
|
|
|
|
let bob_pubkey = solana_sdk::pubkey::new_rand();
|
|
|
|
|
let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getSupply"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let supply: RpcSupply = serde_json::from_value(json["result"]["value"].clone())
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
@@ -4348,7 +4348,7 @@ pub mod tests {
|
|
|
|
|
io, meta, alice, ..
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getLargestAccounts"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let largest_accounts: Vec<RpcAccountBalance> =
|
|
|
|
|
serde_json::from_value(json["result"]["value"].clone())
|
|
|
|
@@ -4385,14 +4385,14 @@ pub mod tests {
|
|
|
|
|
|
|
|
|
|
// Test Circulating/NonCirculating Filter
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getLargestAccounts","params":[{"filter":"circulating"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let largest_accounts: Vec<RpcAccountBalance> =
|
|
|
|
|
serde_json::from_value(json["result"]["value"].clone())
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
assert_eq!(largest_accounts.len(), 20);
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getLargestAccounts","params":[{"filter":"nonCirculating"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let largest_accounts: Vec<RpcAccountBalance> =
|
|
|
|
|
serde_json::from_value(json["result"]["value"].clone())
|
|
|
|
@@ -4438,7 +4438,7 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getInflationGovernor"}"#;
|
|
|
|
|
let rep = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let rep = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let res: Response = serde_json::from_str(&rep.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let inflation_governor: RpcInflationGovernor = if let Response::Single(res) = res {
|
|
|
|
@@ -4454,7 +4454,7 @@ pub mod tests {
|
|
|
|
|
assert_eq!(inflation_governor, expected_inflation_governor);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getInflationRate"}"#; // Queries current epoch
|
|
|
|
|
let rep = io.handle_request_sync(&req, meta);
|
|
|
|
|
let rep = io.handle_request_sync(req, meta);
|
|
|
|
|
let res: Response = serde_json::from_str(&rep.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let inflation_rate: RpcInflationRate = if let Response::Single(res) = res {
|
|
|
|
@@ -4484,7 +4484,7 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getEpochSchedule"}"#;
|
|
|
|
|
let rep = io.handle_request_sync(&req, meta);
|
|
|
|
|
let rep = io.handle_request_sync(req, meta);
|
|
|
|
|
let res: Response = serde_json::from_str(&rep.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -4519,7 +4519,7 @@ pub mod tests {
|
|
|
|
|
]
|
|
|
|
|
.iter()
|
|
|
|
|
{
|
|
|
|
|
let rep = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let rep = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let res: Response = serde_json::from_str(&rep.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -4548,7 +4548,7 @@ pub mod tests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getLeaderSchedule", "params": [42424242]}"#;
|
|
|
|
|
let rep = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let rep = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let res: Response = serde_json::from_str(&rep.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -5415,7 +5415,7 @@ pub mod tests {
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getRecentBlockhash"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = json!({
|
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
|
"result": {
|
|
|
|
@@ -5446,7 +5446,7 @@ pub mod tests {
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getFees"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = json!({
|
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
|
"result": {
|
|
|
|
@@ -5522,7 +5522,7 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getFeeRateGovernor"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = json!({
|
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
|
"result": {
|
|
|
|
@@ -5796,7 +5796,7 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getIdentity"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let expected = json!({
|
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
|
"result": {
|
|
|
|
@@ -5835,7 +5835,7 @@ pub mod tests {
|
|
|
|
|
let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getVersion"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let version = solana_version::Version::default();
|
|
|
|
|
let expected = json!({
|
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
@@ -5930,7 +5930,7 @@ pub mod tests {
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockCommitment","params":[0]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let RpcBlockCommitment {
|
|
|
|
@@ -5956,7 +5956,7 @@ pub mod tests {
|
|
|
|
|
assert_eq!(total_stake, 10);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockCommitment","params":[2]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let commitment_response: RpcBlockCommitment<BlockCommitmentArray> =
|
|
|
|
@@ -5985,7 +5985,7 @@ pub mod tests {
|
|
|
|
|
} = start_rpc_handler_with_tx(&bob_pubkey);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_block: Option<EncodedConfirmedBlock> =
|
|
|
|
@@ -6030,7 +6030,7 @@ pub mod tests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0,"binary"]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_block: Option<EncodedConfirmedBlock> =
|
|
|
|
@@ -6075,7 +6075,7 @@ pub mod tests {
|
|
|
|
|
// disable rpc-tx-history
|
|
|
|
|
meta.config.enable_rpc_transaction_history = false;
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
res,
|
|
|
|
|
Some(
|
|
|
|
@@ -6152,7 +6152,7 @@ pub mod tests {
|
|
|
|
|
.set_highest_confirmed_root(8);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockProduction","params":[]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let block_production: RpcBlockProduction =
|
|
|
|
@@ -6228,35 +6228,35 @@ pub mod tests {
|
|
|
|
|
.set_highest_confirmed_root(8);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, roots[1..].to_vec());
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[2]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![3, 4, 8]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,4]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![1, 3, 4]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,7]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![1, 3, 4]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[9,11]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
@@ -6305,7 +6305,7 @@ pub mod tests {
|
|
|
|
|
.set_highest_confirmed_root(8);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[0,500001]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
assert_eq!(
|
|
|
|
|
res,
|
|
|
|
|
Some(
|
|
|
|
@@ -6314,35 +6314,35 @@ pub mod tests {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[0,0]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert!(confirmed_blocks.is_empty());
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,2]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![3, 4]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,3]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![3, 4, 8]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,500000]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(confirmed_blocks, vec![3, 4, 8]);
|
|
|
|
|
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[9,500000]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
let confirmed_blocks: Vec<Slot> = serde_json::from_value(result["result"].clone()).unwrap();
|
|
|
|
@@ -6410,7 +6410,7 @@ pub mod tests {
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let expected = r#"{"jsonrpc":"2.0","error":{"code":-32004,"message":"Block not available for slot 12345"},"id":1}"#;
|
|
|
|
|
let expected: Response =
|
|
|
|
|
serde_json::from_str(&expected).expect("expected response deserialization");
|
|
|
|
|
serde_json::from_str(expected).expect("expected response deserialization");
|
|
|
|
|
let result: Response = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
assert_eq!(expected, result);
|
|
|
|
@@ -6472,7 +6472,7 @@ pub mod tests {
|
|
|
|
|
// stake but has never voted, and the vote account with no stake should not be present.
|
|
|
|
|
{
|
|
|
|
|
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getVoteAccounts"}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
|
|
|
.expect("actual response deserialization");
|
|
|
|
|
|
|
|
|
@@ -7338,7 +7338,7 @@ pub mod tests {
|
|
|
|
|
);
|
|
|
|
|
let req =
|
|
|
|
|
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(slot, 2);
|
|
|
|
@@ -7353,7 +7353,7 @@ pub mod tests {
|
|
|
|
|
);
|
|
|
|
|
let req =
|
|
|
|
|
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(slot, 2);
|
|
|
|
@@ -7368,7 +7368,7 @@ pub mod tests {
|
|
|
|
|
);
|
|
|
|
|
let req =
|
|
|
|
|
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta.clone());
|
|
|
|
|
let res = io.handle_request_sync(req, meta.clone());
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(slot, 2);
|
|
|
|
@@ -7384,7 +7384,7 @@ pub mod tests {
|
|
|
|
|
);
|
|
|
|
|
let req =
|
|
|
|
|
r#"{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment": "confirmed"}]}"#;
|
|
|
|
|
let res = io.handle_request_sync(&req, meta);
|
|
|
|
|
let res = io.handle_request_sync(req, meta);
|
|
|
|
|
let json: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
|
|
|
|
let slot: Slot = serde_json::from_value(json["result"].clone()).unwrap();
|
|
|
|
|
assert_eq!(slot, 3);
|
|
|
|
|