Skip to content

Commit

Permalink
test(archival_state): Verify expected bounds of archival_block_mmr
Browse files Browse the repository at this point in the history
Verify that tip height can be used to look up a leaf in the archival
block MMR, and that tip height plus 1 cannot.
  • Loading branch information
Sword-Smith committed Jan 22, 2025
1 parent 522a669 commit 2f14913
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/models/state/archival_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,24 @@ mod archival_state_tests {
);
assert_eq!(mock_block_2, archival_state.get_tip().await);
assert_eq!(mock_block_1, archival_state.get_tip_parent().await.unwrap());

assert_eq!(
mock_block_2.hash(),
archival_state
.archival_block_mmr
.try_get_leaf(mock_block_2.header().height.into())
.await
.unwrap(),
"Block Height must be valid leaf index in archival block-MMR"
);
assert!(
archival_state
.archival_block_mmr
.try_get_leaf(mock_block_2.header().height.next().into())
.await
.is_none(),
"Tip height plus 1 must translate into an out-of-bounds leaf index in block-MMR"
);
}

Ok(())
Expand Down

0 comments on commit 2f14913

Please sign in to comment.