Skip to content

Commit 3f4987e

Browse files
committed
fix: temp skip insufficient fee
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent ce8e39f commit 3f4987e

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

tests/integration/account_update_transaction_e2e_test.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import pytest
6+
import datetime
67

78
from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
89
from hiero_sdk_python.account.account_id import AccountId
@@ -201,40 +202,54 @@ def test_integration_account_update_transaction_invalid_auto_renew_period(env):
201202
f"but got {ResponseCode(receipt.status).name}"
202203
)
203204

205+
def _apply_tiny_max_fee_if_supported(tx, client) -> bool:
206+
# Try tx-level setters
207+
for attr in ("set_max_transaction_fee", "set_max_fee", "set_transaction_fee"):
208+
if hasattr(tx, attr):
209+
getattr(tx, attr)(Hbar.from_tinybars(1))
210+
return True
211+
# Try client-level default
212+
for attr in ("set_default_max_transaction_fee", "set_max_transaction_fee",
213+
"set_default_max_fee", "setMaxTransactionFee"):
214+
if hasattr(client, attr):
215+
getattr(client, attr)(Hbar.from_tinybars(1))
216+
return True
217+
return False
204218

205219
@pytest.mark.integration
206-
def test_integration_account_update_transaction_insufficient_fee_large_expiration(env):
207-
"""Test that AccountUpdateTransaction fails with insufficient fee for large expiration time."""
208-
# Create initial account
220+
def test_account_update_insufficient_fee_with_valid_expiration_bump(env):
221+
"""If we can cap the fee, a small valid expiration bump should fail with INSUFFICIENT_TX_FEE; otherwise skip."""
222+
# Create account
209223
receipt = (
210224
AccountCreateTransaction()
211225
.set_key(env.operator_key.public_key())
212226
.set_initial_balance(Hbar(1))
213227
.execute(env.client)
214228
)
215-
assert (
216-
receipt.status == ResponseCode.SUCCESS
217-
), f"Account creation failed with status: {ResponseCode(receipt.status).name}"
218-
229+
assert receipt.status == ResponseCode.SUCCESS
219230
account_id = receipt.account_id
220-
assert account_id is not None, "Account ID should not be None"
221231

222-
# Try to update with a very large expiration time that would require higher fees
223-
large_expiration = Timestamp(seconds=int(1e11), nanos=0)
224-
receipt = (
232+
# Use the account's *current* expiration and bump it slightly forward
233+
info = AccountInfoQuery(account_id).execute(env.client)
234+
base_expiry_secs = int(info.expiration_time.seconds)
235+
236+
delta_seconds = 60 * 60 * 24 # +1 day; typically valid
237+
new_expiry = Timestamp(seconds=base_expiry_secs + delta_seconds, nanos=0)
238+
239+
tx = (
225240
AccountUpdateTransaction()
226241
.set_account_id(account_id)
227-
.set_expiration_time(large_expiration)
228-
.execute(env.client)
242+
.set_expiration_time(new_expiry)
229243
)
230244

231-
# Should fail with INSUFFICIENT_TX_FEE
245+
if not _apply_tiny_max_fee_if_supported(tx, env.client):
246+
pytest.skip("SDK lacks a max-fee API; cannot deterministically trigger INSUFFICIENT_TX_FEE.")
247+
248+
receipt = tx.execute(env.client)
232249
assert receipt.status == ResponseCode.INSUFFICIENT_TX_FEE, (
233-
f"Account update should have failed with status INSUFFICIENT_TX_FEE, "
234-
f"but got {ResponseCode(receipt.status).name}"
250+
f"Expected INSUFFICIENT_TX_FEE but got {ResponseCode(receipt.status).name}"
235251
)
236252

237-
238253
@pytest.mark.integration
239254
def test_integration_account_update_transaction_with_only_account_id(env):
240255
"""Test that AccountUpdateTransaction can execute with only account ID set."""

0 commit comments

Comments
 (0)