From 800141446c9d522139a5fa95deca513e83888794 Mon Sep 17 00:00:00 2001 From: Janito Vaqueiro Ferreira Filho Date: Mon, 4 Oct 2021 10:31:56 -0300 Subject: [PATCH] Tweak some assertions to better match their error messages (#2822) * Change assertion condition to match message Refactor the condition so that the expression is easier to compare to the panic message. * Change comparison order to match panic message Change the order of the equality so that it matches the panic message. --- zebra-chain/src/history_tree.rs | 2 +- zebra-chain/src/primitives/zcash_history.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zebra-chain/src/history_tree.rs b/zebra-chain/src/history_tree.rs index 8453adb94..7b133edc3 100644 --- a/zebra-chain/src/history_tree.rs +++ b/zebra-chain/src/history_tree.rs @@ -200,7 +200,7 @@ impl NonEmptyHistoryTree { .expect("block must have coinbase height during contextual verification"); assert!( - height - self.current_height == 1, + Some(height) == self.current_height + 1, "added block with height {:?} but it must be {:?}+1", height, self.current_height diff --git a/zebra-chain/src/primitives/zcash_history.rs b/zebra-chain/src/primitives/zcash_history.rs index f4438faf4..5dd4bef6f 100644 --- a/zebra-chain/src/primitives/zcash_history.rs +++ b/zebra-chain/src/primitives/zcash_history.rs @@ -184,7 +184,7 @@ impl Tree { let network_upgrade = NetworkUpgrade::current(self.network, height); assert!( - self.network_upgrade == network_upgrade, + network_upgrade == self.network_upgrade, "added block from network upgrade {:?} but history tree is restricted to {:?}", network_upgrade, self.network_upgrade