66from hiero_sdk_python .exceptions import PrecheckError
77from hiero_sdk_python .hbar import Hbar
88from hiero_sdk_python .query .account_balance_query import CryptoGetAccountBalanceQuery
9+ from hiero_sdk_python .query .account_info_query import AccountInfoQuery
910from hiero_sdk_python .query .token_info_query import TokenInfoQuery
1011from 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
1415def 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+
0 commit comments