Skip to content

Commit

Permalink
fixed get_blockchain_info bug in zaino-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
idky137 committed Dec 6, 2024
1 parent 750a55d commit 3ae79e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 1 addition & 5 deletions zaino-fetch/src/jsonrpc/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ pub struct GetBlockchainInfoResponse {
#[serde(rename = "estimatedheight")]
pub estimated_height: zebra_chain::block::Height,

/// Value pool balances
#[serde(rename = "valuePools")]
pub value_pools: [zebra_rpc::methods::types::ValuePoolBalance; 5],

/// Status of network upgrades
pub upgrades: indexmap::IndexMap<
zebra_rpc::methods::ConsensusBranchIdHex,
Expand All @@ -59,7 +55,7 @@ impl From<GetBlockchainInfoResponse> for zebra_rpc::methods::GetBlockChainInfo {
response.blocks,
response.best_block_hash,
response.estimated_height,
response.value_pools,
zebra_rpc::methods::types::ValuePoolBalance::zero_pools(),
response.upgrades,
response.consensus,
)
Expand Down
21 changes: 19 additions & 2 deletions zaino-state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,27 @@ mod tests {
let fetch_start = tokio::time::Instant::now();
let fetch_service_get_blockchain_info = fetch_service.get_blockchain_info().await.unwrap();
let fetch_service_duration = fetch_start.elapsed();
let fetch_service_get_blockchain_info: GetBlockChainInfo =
fetch_service_get_blockchain_info.into();

// Zaino-Fetch does not return value_pools, ingnore this field.
assert_eq!(
state_service_get_blockchain_info,
fetch_service_get_blockchain_info.into()
(
state_service_get_blockchain_info.chain(),
state_service_get_blockchain_info.blocks(),
state_service_get_blockchain_info.best_block_hash(),
state_service_get_blockchain_info.estimated_height(),
state_service_get_blockchain_info.upgrades(),
state_service_get_blockchain_info.consensus(),
),
(
fetch_service_get_blockchain_info.chain(),
fetch_service_get_blockchain_info.blocks(),
fetch_service_get_blockchain_info.best_block_hash(),
fetch_service_get_blockchain_info.estimated_height(),
fetch_service_get_blockchain_info.upgrades(),
fetch_service_get_blockchain_info.consensus(),
)
);

println!("GetBlockChainInfo responses correct. State-Service processing time: {:?} - fetch-Service processing time: {:?}.", state_service_duration, fetch_service_duration);
Expand Down

0 comments on commit 3ae79e5

Please sign in to comment.