Skip to content

Commit

Permalink
test(mine_loop): Verify fast mast-hash agrees with trait function
Browse files Browse the repository at this point in the history
Verify that the slow and fast way of calculating the kernel MAST hash
for a block agree.
  • Loading branch information
Sword-Smith committed Jan 16, 2025
1 parent 37695fd commit aead042
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mine_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ pub(crate) mod mine_loop_tests {
use crate::config_models::cli_args;
use crate::config_models::network::Network;
use crate::job_queue::triton_vm::TritonVmJobQueue;
use crate::models::blockchain::block::validity::block_primitive_witness::test::deterministic_block_primitive_witness;
use crate::models::blockchain::transaction::validity::single_proof::SingleProof;
use crate::models::blockchain::type_scripts::neptune_coins::NeptuneCoins;
use crate::models::proof_abstractions::mast_hash::MastHash;
Expand Down Expand Up @@ -1631,6 +1632,17 @@ pub(crate) mod mine_loop_tests {
Ok(())
}

#[test]
fn fast_kernel_mast_hash_agrees_with_mast_hash_function() {
let block_primitive_witness = deterministic_block_primitive_witness();
let a_block = block_primitive_witness.predecessor_block();
let (kernel_auth_path, header_auth_path) = precalculate_block_auth_paths(&a_block);
assert_eq!(
a_block.kernel.mast_hash(),
fast_kernel_mast_hash(kernel_auth_path, header_auth_path, a_block.header().nonce)
);
}

#[traced_test]
#[tokio::test]
async fn mine_20_blocks_in_40_seconds() -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ pub(crate) mod test {
}

impl BlockPrimitiveWitness {
pub(crate) fn predecessor_block(&self) -> Block {
self.predecessor_block.to_owned()
}

pub(crate) fn arbitrary() -> BoxedStrategy<BlockPrimitiveWitness> {
const NUM_INPUTS: usize = 2;
(
Expand Down

0 comments on commit aead042

Please sign in to comment.