Fix some failing gRPC tests. (#4424)

This commit is contained in:
Marek 2022-05-19 04:30:34 +02:00 committed by GitHub
parent 9aaf0ed0ce
commit ec9b569ebf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 7 deletions

View File

@ -31,7 +31,9 @@
use color_eyre::eyre::Result; use color_eyre::eyre::Result;
use zebra_chain::{ use zebra_chain::{
block::Block, parameters::Network, parameters::NetworkUpgrade::Canopy, block::Block,
parameters::Network,
parameters::NetworkUpgrade::{self, Canopy},
serialization::ZcashDeserializeInto, serialization::ZcashDeserializeInto,
}; };
@ -107,27 +109,34 @@ pub async fn run() -> Result<()> {
// As we are using a pretty much synchronized blockchain, we can assume the tip is above the Canopy network upgrade // As we are using a pretty much synchronized blockchain, we can assume the tip is above the Canopy network upgrade
assert!(block_tip.height > Canopy.activation_height(network).unwrap().0 as u64); assert!(block_tip.height > Canopy.activation_height(network).unwrap().0 as u64);
// `lightwalletd` only supports post-Sapling blocks, so we begin at the
// Sapling activation height.
let sapling_activation_height = NetworkUpgrade::Sapling
.activation_height(network)
.unwrap()
.0 as u64;
// Call `GetBlock` with block 1 height // Call `GetBlock` with block 1 height
let block_one = rpc_client let block_one = rpc_client
.get_block(BlockId { .get_block(BlockId {
height: 1, height: sapling_activation_height,
hash: vec![], hash: vec![],
}) })
.await? .await?
.into_inner(); .into_inner();
// Make sure we got block 1 back // Make sure we got block 1 back
assert_eq!(block_one.height, 1); assert_eq!(block_one.height, sapling_activation_height);
// Call `GetBlockRange` with the range starting at block 1 up to block 10 // Call `GetBlockRange` with the range starting at block 1 up to block 10
let mut block_range = rpc_client let mut block_range = rpc_client
.get_block_range(BlockRange { .get_block_range(BlockRange {
start: Some(BlockId { start: Some(BlockId {
height: 1, height: sapling_activation_height,
hash: vec![], hash: vec![],
}), }),
end: Some(BlockId { end: Some(BlockId {
height: 10, height: sapling_activation_height + 10,
hash: vec![], hash: vec![],
}), }),
}) })
@ -135,10 +144,10 @@ pub async fn run() -> Result<()> {
.into_inner(); .into_inner();
// Make sure the returned Stream of blocks is what we expect // Make sure the returned Stream of blocks is what we expect
let mut counter = 0; let mut counter = sapling_activation_height;
while let Some(block) = block_range.message().await? { while let Some(block) = block_range.message().await? {
counter += 1;
assert_eq!(block.height, counter); assert_eq!(block.height, counter);
counter += 1;
} }
// Get the first transction of the first block in the mainnet // Get the first transction of the first block in the mainnet