Skip to content

Commit

Permalink
fix(gtest): Fix gas tree ops to avoid split/split_with_value when…
Browse files Browse the repository at this point in the history
… both reply is sent and reply deposit exists (#4270)
  • Loading branch information
techraed authored Sep 30, 2024
1 parent 8ad1139 commit 5d67331
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions gtest/src/manager/journal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions gtest/src/state/gas_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<PlainNodeId>()))
if !is_reply || !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::<PlainNodeId>()))
{
return GasTree::split_with_value(
GasNodeId::from(original_mid.cast::<PlainNodeId>()),
Expand All @@ -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::<PlainNodeId>()))
if !is_reply || !GasTree::exists_and_deposit(GasNodeId::from(new_mid.cast::<PlainNodeId>()))
{
return GasTree::split(
GasNodeId::from(original_node.cast::<PlainNodeId>()),
Expand Down

0 comments on commit 5d67331

Please sign in to comment.