Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gtest): Fix gas tree ops to avoid split/split_with_value when both reply is sent and reply deposit exists #4270

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading