Skip to content

Commit 5cb9107

Browse files
committed
fix: honor explicit zero fee in scheduled bodies
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent fb81c76 commit 5cb9107

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ def build_base_scheduled_body(self) -> SchedulableTransactionBody:
513513
"""
514514
schedulable_body = SchedulableTransactionBody()
515515

516-
fee = self._transaction_fee or self._default_transaction_fee
517-
if hasattr(fee, "to_tinybars"):
516+
fee = self._transaction_fee if self._transaction_fee is not None else self._default_transaction_fee
517+
if isinstance(fee, Hbar):
518518
schedulable_body.transactionFee = int(fee.to_tinybars())
519519
else:
520520
schedulable_body.transactionFee = int(fee)

tests/unit/transaction_freeze_and_bytes_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from hiero_sdk_python.account.account_id import AccountId
1717
from hiero_sdk_python.crypto.private_key import PrivateKey
18+
from hiero_sdk_python.hapi.services import transaction_pb2
1819
from hiero_sdk_python.hapi.services.transaction_response_pb2 import (
1920
TransactionResponse as TransactionResponseProto,
2021
)
@@ -795,6 +796,20 @@ def test_max_transaction_fee_survives_to_bytes_round_trip(mock_client):
795796
assert restored._transaction_fee == Hbar(2).to_tinybars()
796797

797798

799+
def test_explicit_zero_fee_is_honored_on_direct_and_scheduled_paths(mock_client):
800+
"""An explicit zero fee must reach both the direct and the scheduled body unchanged."""
801+
tx = TransferTransaction()
802+
tx.set_max_transaction_fee(Hbar(0))
803+
804+
scheduled_body = tx.build_base_scheduled_body()
805+
assert scheduled_body.transactionFee == 0
806+
807+
tx.freeze_with(mock_client)
808+
body = transaction_pb2.TransactionBody()
809+
body.ParseFromString(next(iter(tx._transaction_body_bytes.values())))
810+
assert body.transactionFee == 0
811+
812+
798813
def test_freeze_with_bare_magicmock_client_resolves_default_fee():
799814
"""Freezing against a bare MagicMock client must not raise and must fall back to the per-type default fee."""
800815
tx = TransferTransaction()

0 commit comments

Comments
 (0)