Delete duplicate test code for chain verifier
This code was commented-out, so the tests weren't actually running.
This commit is contained in:
parent
436a4e9a5b
commit
b8cc3bfb23
|
|
@ -253,126 +253,3 @@ async fn verify_fail_add_block_checkpoint() -> Result<(), Report> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// This test is disabled because it doesn't test the right thing:
|
|
||||||
// the BlockVerifier and CheckpointVerifier make different requests
|
|
||||||
// and produce different transcripts.
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
// Temporarily ignore this test, until the state can handle out-of-order blocks
|
|
||||||
#[ignore]
|
|
||||||
async fn continuous_blockchain_test() -> Result<(), Report> {
|
|
||||||
continuous_blockchain(None).await?;
|
|
||||||
for height in 0..=10 {
|
|
||||||
continuous_blockchain(Some(block::Height(height))).await?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Test a continuous blockchain in the BlockVerifier and CheckpointVerifier,
|
|
||||||
/// restarting verification at `restart_height`.
|
|
||||||
#[spandoc::spandoc]
|
|
||||||
async fn continuous_blockchain(restart_height: Option<block::Height>) -> Result<(), Report> {
|
|
||||||
zebra_test::init();
|
|
||||||
let network = Network::Mainnet;
|
|
||||||
|
|
||||||
// A continuous blockchain
|
|
||||||
let mut blockchain = Vec::new();
|
|
||||||
for b in &[
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_1_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_2_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_3_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_4_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_5_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_6_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_7_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_8_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_9_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_10_BYTES[..],
|
|
||||||
] {
|
|
||||||
let block = Arc::<Block>::zcash_deserialize(*b)?;
|
|
||||||
let hash = block.hash();
|
|
||||||
blockchain.push((block.clone(), block.coinbase_height().unwrap(), hash));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse only some blocks as checkpoints
|
|
||||||
let mut checkpoints = Vec::new();
|
|
||||||
for b in &[
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..],
|
|
||||||
&zebra_test::vectors::BLOCK_MAINNET_4_BYTES[..],
|
|
||||||
] {
|
|
||||||
let block = Arc::<Block>::zcash_deserialize(*b)?;
|
|
||||||
let hash = block.hash();
|
|
||||||
checkpoints.push((block.clone(), block.coinbase_height().unwrap(), hash));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The checkpoint list will contain only blocks 0 and 4
|
|
||||||
let checkpoint_list: BTreeMap<block::Height, block::Hash> = checkpoints
|
|
||||||
.iter()
|
|
||||||
.map(|(_block, height, hash)| (*height, *hash))
|
|
||||||
.collect();
|
|
||||||
let checkpoint_list = CheckpointList::from_list(checkpoint_list).map_err(|e| eyre!(e))?;
|
|
||||||
|
|
||||||
let mut state_service = zs::init(zs::Config::ephemeral(), network);
|
|
||||||
/// SPANDOC: Add blocks to the state from 0..=restart_height {?restart_height}
|
|
||||||
if restart_height.is_some() {
|
|
||||||
for block in blockchain
|
|
||||||
.iter()
|
|
||||||
.take((restart_height.unwrap().0 + 1) as usize)
|
|
||||||
.map(|(block, ..)| block)
|
|
||||||
{
|
|
||||||
state_service
|
|
||||||
.ready_and()
|
|
||||||
.map_err(|e| eyre!(e))
|
|
||||||
.await?
|
|
||||||
.call(zs::Request::AddBlock {
|
|
||||||
block: block.clone(),
|
|
||||||
})
|
|
||||||
.map_err(|e| eyre!(e))
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let initial_tip = restart_height
|
|
||||||
.map(|block::Height(height)| &blockchain[height as usize].0)
|
|
||||||
.cloned();
|
|
||||||
|
|
||||||
let block_verifier = crate::block::init(state_service.clone());
|
|
||||||
let mut chain_verifier = super::init_from_verifiers(
|
|
||||||
network,
|
|
||||||
block_verifier,
|
|
||||||
Some(checkpoint_list),
|
|
||||||
state_service.clone(),
|
|
||||||
initial_tip,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut handles = FuturesUnordered::new();
|
|
||||||
|
|
||||||
/// SPANDOC: Verify blocks, restarting at restart_height {?restart_height}
|
|
||||||
for (block, height, _hash) in blockchain
|
|
||||||
.iter()
|
|
||||||
.filter(|(_, height, _)| restart_height.map_or(true, |rh| *height > rh))
|
|
||||||
{
|
|
||||||
/// SPANDOC: Make sure the verifier service is ready for the block at height {?height}
|
|
||||||
let ready_verifier_service = chain_verifier.ready_and().map_err(|e| eyre!(e)).await?;
|
|
||||||
|
|
||||||
/// SPANDOC: Set up the future for block {?height}
|
|
||||||
let verify_future = timeout(
|
|
||||||
std::time::Duration::from_secs(VERIFY_TIMEOUT_SECONDS),
|
|
||||||
ready_verifier_service.call(block.clone()),
|
|
||||||
);
|
|
||||||
|
|
||||||
/// SPANDOC: spawn verification future in the background for block {?height}
|
|
||||||
let handle = tokio::spawn(verify_future.in_current_span());
|
|
||||||
handles.push(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
while let Some(result) = handles.next().await {
|
|
||||||
result??.map_err(|e| eyre!(e))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,6 @@ async fn continuous_blockchain_restart() -> Result<(), Report> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test a continuous blockchain, restarting verification at `restart_height`.
|
/// Test a continuous blockchain, restarting verification at `restart_height`.
|
||||||
// TODO: does this duplicate the test code commented out in src/chain/tests.rs?
|
|
||||||
#[spandoc::spandoc]
|
#[spandoc::spandoc]
|
||||||
async fn continuous_blockchain(restart_height: Option<block::Height>) -> Result<(), Report> {
|
async fn continuous_blockchain(restart_height: Option<block::Height>) -> Result<(), Report> {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue