From 5d67331a6d3abe64881f7da92d1b6eb8931e8909 Mon Sep 17 00:00:00 2001 From: Sabaun Taraki Date: Mon, 30 Sep 2024 20:20:09 +0300 Subject: [PATCH] fix(gtest): Fix gas tree ops to avoid `split`/`split_with_value` when both reply is sent and reply deposit exists (#4270) --- gtest/src/manager/journal.rs | 6 +++--- gtest/src/state/gas_tree.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gtest/src/manager/journal.rs b/gtest/src/manager/journal.rs index a41604cf1e2..b01bc334884 100644 --- a/gtest/src/manager/journal.rs +++ b/gtest/src/manager/journal.rs @@ -164,15 +164,15 @@ impl JournalHandler for ExtManager { match (gas_limit, reservation) { (Some(gas_limit), None) => self .gas_tree - .split_with_value(false, message_id, dispatch.id(), gas_limit) + .split_with_value(dispatch.is_reply(), message_id, dispatch.id(), gas_limit) .unwrap_or_else(|e| unreachable!("GasTree corrupted! {:?}", e)), (None, None) => self .gas_tree - .split(false, message_id, dispatch.id()) + .split(dispatch.is_reply(), message_id, dispatch.id()) .unwrap_or_else(|e| unreachable!("GasTree corrupted! {:?}", e)), (None, Some(reservation)) => { self.gas_tree - .split(false, reservation, dispatch.id()) + .split(dispatch.is_reply(), reservation, dispatch.id()) .unwrap_or_else(|e| unreachable!("GasTree corrupted! {:?}", e)); self.remove_gas_reservation_with_task(dispatch.source(), reservation); } diff --git a/gtest/src/state/gas_tree.rs b/gtest/src/state/gas_tree.rs index ef2d1a9e34e..98435d98780 100644 --- a/gtest/src/state/gas_tree.rs +++ b/gtest/src/state/gas_tree.rs @@ -88,7 +88,7 @@ impl GasTreeManager { new_mid: MessageId, amount: Gas, ) -> Result<(), GasTreeError> { - if !is_reply && !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::())) + if !is_reply || !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::())) { return GasTree::split_with_value( GasNodeId::from(original_mid.cast::()), @@ -107,7 +107,7 @@ impl GasTreeManager { original_node: impl Origin, new_mid: MessageId, ) -> Result<(), GasTreeError> { - if !is_reply && !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::())) + if !is_reply || !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::())) { return GasTree::split( GasNodeId::from(original_node.cast::()),