test
This commit is contained in:
parent
7f97b62845
commit
ec15e98b70
|
@ -1,6 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
use log::info;
|
||||||
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
@ -91,6 +92,7 @@ impl BlockStore {
|
||||||
block_info: BlockInformation,
|
block_info: BlockInformation,
|
||||||
commitment_config: CommitmentConfig,
|
commitment_config: CommitmentConfig,
|
||||||
) {
|
) {
|
||||||
|
info!("{commitment_config:?} {blockhash:?}, {block_info:?}");
|
||||||
// Write to block store first in order to prevent
|
// Write to block store first in order to prevent
|
||||||
// any race condition i.e prevent some one to
|
// any race condition i.e prevent some one to
|
||||||
// ask the map what it doesn't have rn
|
// ask the map what it doesn't have rn
|
||||||
|
|
|
@ -18,13 +18,10 @@ use solana_transaction_status::{
|
||||||
option_serializer::OptionSerializer, RewardType, TransactionConfirmationStatus,
|
option_serializer::OptionSerializer, RewardType, TransactionConfirmationStatus,
|
||||||
TransactionStatus, UiConfirmedBlock, UiTransactionStatusMeta,
|
TransactionStatus, UiConfirmedBlock, UiTransactionStatusMeta,
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::{sync::mpsc::Sender, task::JoinHandle};
|
||||||
sync::{mpsc::Sender},
|
|
||||||
task::JoinHandle,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block_store::{BlockStore},
|
block_store::BlockStore,
|
||||||
workers::{PostgresBlock, PostgresMsg, PostgresUpdateTx},
|
workers::{PostgresBlock, PostgresMsg, PostgresUpdateTx},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,7 +37,7 @@ pub struct BlockListener {
|
||||||
pub signature_subscribers: Arc<DashMap<String, SubscriptionSink>>,
|
pub signature_subscribers: Arc<DashMap<String, SubscriptionSink>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BlockInformation {
|
pub struct BlockInformation {
|
||||||
pub slot: u64,
|
pub slot: u64,
|
||||||
pub block_height: u64,
|
pub block_height: u64,
|
||||||
|
@ -119,7 +116,7 @@ impl BlockListener {
|
||||||
info!("Listening to {commitment:?} blocks");
|
info!("Listening to {commitment:?} blocks");
|
||||||
|
|
||||||
while let Some(block) = recv.as_mut().next().await {
|
while let Some(block) = recv.as_mut().next().await {
|
||||||
let slot = block.value.slot;
|
let slot = block.context.slot;
|
||||||
|
|
||||||
let Some(block) = block.value.block else {
|
let Some(block) = block.value.block else {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
use lite_rpc::{DEFAULT_LITE_RPC_ADDR, DEFAULT_RPC_ADDR};
|
||||||
|
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||||
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn diff_rpc() -> anyhow::Result<()> {
|
||||||
|
let rpc_client = RpcClient::new(DEFAULT_RPC_ADDR.to_string());
|
||||||
|
let lite_rpc_client = RpcClient::new(DEFAULT_LITE_RPC_ADDR.to_string());
|
||||||
|
|
||||||
|
check_block_hash(&rpc_client, &lite_rpc_client, CommitmentConfig::confirmed()).await?;
|
||||||
|
check_block_hash(&rpc_client, &lite_rpc_client, CommitmentConfig::finalized()).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_block_hash(
|
||||||
|
rpc_client: &RpcClient,
|
||||||
|
lite_rpc_client: &RpcClient,
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let rpc_blockhash = rpc_client
|
||||||
|
.get_latest_blockhash_with_commitment(commitment_config)
|
||||||
|
.await?;
|
||||||
|
let lite_blockhash = lite_rpc_client
|
||||||
|
.get_latest_blockhash_with_commitment(commitment_config)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("{commitment_config:?} {rpc_blockhash:?} {lite_blockhash:?}");
|
||||||
|
|
||||||
|
assert_eq!(rpc_blockhash.0, lite_blockhash.0);
|
||||||
|
assert_eq!(rpc_blockhash.1, lite_blockhash.1);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in New Issue