From 099f241b9029236fc0a6746e192454147d0dcba7 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 24 Mar 2023 18:37:23 +0200 Subject: [PATCH] test(execution): extending with empty poststate (#1969) --- crates/storage/provider/src/post_state.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/storage/provider/src/post_state.rs b/crates/storage/provider/src/post_state.rs index 5378b424d2..39f35fd01d 100644 --- a/crates/storage/provider/src/post_state.rs +++ b/crates/storage/provider/src/post_state.rs @@ -598,6 +598,25 @@ mod tests { }; use std::sync::Arc; + // Ensure that the transition id is not incremented if postate is extended by another empty + // poststate. + #[test] + fn extend_empty() { + let mut a = PostState::new(); + assert_eq!(a.current_transition_id, 0); + + // Extend empty poststate with another empty poststate + a.extend(PostState::new()); + assert_eq!(a.current_transition_id, 0); + + // Add single transition and extend with empty poststate + a.create_account(Address::zero(), Account::default()); + a.finish_transition(); + let transition_id = a.current_transition_id; + a.extend(PostState::new()); + assert_eq!(a.current_transition_id, transition_id); + } + #[test] fn extend() { let mut a = PostState::new();