adds test for semantic validation

This commit is contained in:
Arya 2024-11-15 20:41:23 -05:00
parent 62bfef3fe0
commit b365c9d173
1 changed files with 29 additions and 0 deletions

View File

@ -2,12 +2,14 @@
use std::{sync::Arc, time::Duration};
use block::genesis::regtest_genesis_block;
use color_eyre::eyre::Report;
use once_cell::sync::Lazy;
use tower::{layer::Layer, timeout::TimeoutLayer};
use zebra_chain::{
block::Block,
orchard_zsa::tests::vectors::valid_issuance_blocks,
serialization::{ZcashDeserialize, ZcashDeserializeInto},
};
use zebra_state as zs;
@ -270,3 +272,30 @@ async fn verify_fail_add_block_checkpoint() -> Result<(), Report> {
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn verify_issuance_blocks_test() -> Result<(), Report> {
let _init_guard = zebra_test::init();
let network = Network::new_regtest(Some(1), None, Some(1));
let (block_verifier_router, _state_service) = verifiers_from_network(network.clone()).await;
let block_verifier_router =
TimeoutLayer::new(Duration::from_secs(VERIFY_TIMEOUT_SECONDS)).layer(block_verifier_router);
let commit_genesis = [(
Request::Commit(regtest_genesis_block()),
Ok(network.genesis_hash()),
)];
let commit_issuance_blocks = valid_issuance_blocks()
.into_iter()
.map(|block| (Request::Commit(block.clone()), Ok(block.hash())));
Transcript::from(commit_genesis.into_iter().chain(commit_issuance_blocks))
.check(block_verifier_router.clone())
.await
.unwrap();
Ok(())
}