Skip to content

Commit 8ee657c

Browse files
committed
feat: added integratiion test
Signed-off-by: Manish Dait <[email protected]>
1 parent d046b48 commit 8ee657c

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

tests/integration/query_e2e_test.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
from hiero_sdk_python.exceptions import PrecheckError
77
from hiero_sdk_python.hbar import Hbar
88
from hiero_sdk_python.query.account_balance_query import CryptoGetAccountBalanceQuery
9+
from hiero_sdk_python.query.account_info_query import AccountInfoQuery
910
from hiero_sdk_python.query.token_info_query import TokenInfoQuery
1011
from hiero_sdk_python.response_code import ResponseCode
11-
from tests.integration.utils import IntegrationTestEnv, create_fungible_token
12+
from tests.integration.utils import IntegrationTestEnv, env, create_fungible_token
1213

1314
@pytest.mark.integration
1415
def test_integration_free_query_no_cost():
@@ -236,4 +237,24 @@ def test_integration_paid_query_payment_too_high_fails():
236237
with pytest.raises(PrecheckError, match="failed precheck with status: INSUFFICIENT_PAYER_BALANCE"):
237238
query.execute(env.client)
238239
finally:
239-
env.close()
240+
env.close()
241+
242+
@pytest.mark.integration
243+
def test_integration_query_exceeds_max_payment(env):
244+
"""Test that Query fails when cost exceeds max_query_payment."""
245+
receipt = env.create_account(1)
246+
account_id = receipt.id
247+
248+
# Set max payment below actual cost
249+
query = (
250+
AccountInfoQuery()
251+
.set_account_id(account_id)
252+
.set_max_query_payment(Hbar.from_tinybars(1)) # Intentionally too low to fail
253+
)
254+
255+
with pytest.raises(ValueError) as e:
256+
query.execute(env.client)
257+
258+
msg = str(e.value)
259+
assert "Query cost" in msg and "exceeds max set query payment:" in msg
260+

tests/unit/query_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ def test_set_max_payment_override_client_max_payment_and_error(query_requires_pa
328328
# Mock get_cost to return 2 Hbar, exceeding the query.max_query_payment
329329
mock_get_cost = MagicMock(return_value=Hbar(2))
330330
query_requires_payment.get_cost = mock_get_cost
331-
query_requires_payment.get_cost = mock_get_cost
332331

333332
# Execution should raise ValueError because 2 > query.max_query_payment (1)
334333
expected_msg = "Query cost ℏ2.0 HBAR exceeds max set query payment: ℏ1.0 HBAR"
@@ -367,7 +366,6 @@ def test_payment_query_use_client_max_payment_and_error(query_requires_payment,
367366
# Mock get_cost to return 2 Hbar, exceeding the client.default_max_query_payment
368367
mock_get_cost = MagicMock(return_value=Hbar(2))
369368
query_requires_payment.get_cost = mock_get_cost
370-
query_requires_payment.get_cost = mock_get_cost
371369

372370
# Execution should raise ValueError because 2 > client.default_max_query_payment
373371
expected_msg = "Query cost ℏ2.0 HBAR exceeds max set query payment: ℏ1.0 HBAR"

0 commit comments

Comments
 (0)