Skip to content

Commit c3945ed

Browse files
committed
fix: adding the new names for exceptions as per devnet5 along with devnet4
1 parent aecebf1 commit c3945ed

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

testing/lean-spec-tests/src/state_transition.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ pub fn run_state_transition_test(
4242
let mut state = LeanState::try_from(test.pre.clone())
4343
.map_err(|err| anyhow!("Failed to convert pre-state: {err}"))?;
4444

45-
// Track whether we expect an exception
46-
let expect_exception = test.expect_exception.is_some();
45+
// Track whether we expect an exception (devnet4: expectException, devnet5: rejectionReason)
46+
let expect_exception = test.expects_failure();
4747
if expect_exception {
48-
info!(
49-
"Expected result: Exception: {}",
50-
test.expect_exception
51-
.as_ref()
52-
.expect("Failed to fetch expected exception")
53-
);
48+
let reason = test.expect_exception.as_deref()
49+
.or(test.rejection_reason.as_deref())
50+
.unwrap_or("unknown");
51+
info!("Expected result: Exception: {reason}");
5452
} else {
5553
info!("Expected result: Success");
5654
}
@@ -95,12 +93,10 @@ pub fn run_state_transition_test(
9593
// Check if the result matches expectations
9694
match (result, expect_exception) {
9795
(Ok(_), true) => {
98-
bail!(
99-
"Expected exception '{}' but state transition succeeded",
100-
test.expect_exception
101-
.as_ref()
102-
.expect("Failed to fetch expected exception")
103-
);
96+
let reason = test.expect_exception.as_deref()
97+
.or(test.rejection_reason.as_deref())
98+
.unwrap_or("unknown");
99+
bail!("Expected exception '{reason}' but state transition succeeded");
104100
}
105101
(Err(err), false) => {
106102
bail!("State transition should succeed but failed: {err}");

testing/lean-spec-tests/src/types/state_transition.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ pub struct StateTransitionTest {
1111
pub pre: State,
1212
pub blocks: Vec<Block>,
1313
pub post: Option<StateExpectation>,
14+
/// devnet4 field name for expected failure
1415
pub expect_exception: Option<String>,
16+
/// devnet5 field name for expected failure
17+
pub rejection_reason: Option<String>,
18+
}
19+
20+
impl StateTransitionTest {
21+
pub fn expects_failure(&self) -> bool {
22+
self.expect_exception.is_some() || self.rejection_reason.is_some()
23+
}
1524
}
1625

1726
/// State expectations for state transition tests

0 commit comments

Comments
 (0)