Skip to content

Commit

Permalink
adds test for semantic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Nov 16, 2024
1 parent 62bfef3 commit b365c9d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions zebra-consensus/src/router/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}

0 comments on commit b365c9d

Please sign in to comment.