Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/blockchain/state_transition/tests/stf_spectests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ fn run(path: &Path) -> datatest_stable::Result<()> {
match (result, test.post) {
(Ok(_), Some(expected_post)) => {
compare_post_states(&post_state, &expected_post, &block_registry)?;
// Hardening: the full post-state hash_tree_root must equal the
// fixture's `postStateRoot`. The per-field `post` checks only
// pin the fields the fixture chose to enumerate; this catches
// any state field they omit.
if let Some(expected_root) = test.post_state_root {
Comment thread
MegaRedHand marked this conversation as resolved.
let actual_root = post_state.hash_tree_root();
if actual_root != expected_root {
return Err(format!(
"Test '{name}' post-state root mismatch: \
expected {expected_root:?}, got {actual_root:?}"
)
.into());
}
}
}
(Ok(_), None) => {
return Err(
Expand Down
7 changes: 3 additions & 4 deletions crates/blockchain/state_transition/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ pub struct StateTransitionTest {
pub pre: TestState,
pub blocks: Vec<Block>,
pub post: Option<PostState>,
/// Expected post-state `hash_tree_root`, present alongside `post`. Captured
/// only so `deny_unknown_fields` accepts it; the per-field `post` checks
/// already pin the post-state.
/// Expected post-state `hash_tree_root`, present alongside `post`. Asserted
/// against the full post-state root after the per-field `post` checks, so
/// any state field those checks don't enumerate is still pinned.
#[serde(rename = "postStateRoot")]
#[allow(dead_code)]
pub post_state_root: Option<H256>,
/// Expected rejection reason for negative cases. Captured only so
/// `deny_unknown_fields` accepts it; failure is asserted via a missing
Expand Down