1212import pytest
1313
1414from hiero_sdk_python .account .account_id import AccountId
15+ from hiero_sdk_python .client .client import Client
1516from hiero_sdk_python .exceptions import ReceiptStatusError
1617from hiero_sdk_python .hapi .services import (
1718 basic_types_pb2 ,
@@ -253,6 +254,73 @@ def test_transaction_response_get_receipt_is_pinned_to_submitting_node(
253254 assert receipt .status == ResponseCode .SUCCESS
254255
255256
257+ @pytest .mark .parametrize ("status" , [1 , 1.2 , None , Client (), "True" , [], {}])
258+ def test_get_receipt_query_invalid_status_type (status ):
259+ """Test that get_receipt_query raises TypeError for an invalid status type."""
260+ response = TransactionResponse ()
261+ with pytest .raises (TypeError , match = "validate_status must be a boolean" ):
262+ response .get_receipt_query (validate_status = status )
263+
264+
265+ @pytest .mark .parametrize (
266+ "client" ,
267+ [1 , 1.2 , True , "True" , [], {}], # None is allow for client
268+ )
269+ def test_get_receipt_query_invalid_client_type (client ):
270+ """Test that get_receipt_query raises TypeError for an invalid client type."""
271+ response = TransactionResponse ()
272+ with pytest .raises (TypeError , match = "client must be an instance of Client" ):
273+ response .get_receipt_query (client = client )
274+
275+
276+ @pytest .mark .parametrize (
277+ "client" ,
278+ [1 , 1.2 , True , "True" , [], {}], # None is allow for client
279+ )
280+ def test_get_record_query_invalid_client_type (client ):
281+ """Test that get_record_query raises TypeError for an invalid client type."""
282+ response = TransactionResponse ()
283+ with pytest .raises (TypeError , match = "client must be an instance of Client" ):
284+ response .get_record_query (client = client )
285+
286+
287+ def test_resolve_node_account_ids_with_failover_diabled (mock_client ):
288+ """Test that only the transaction node is returned when no client or failover is disabled."""
289+ response = TransactionResponse ()
290+ response .node_id = AccountId .from_string ("0.0.3" )
291+
292+ # When client is None
293+ node_ids = response ._resolve_node_account_ids (None )
294+ assert node_ids == [AccountId .from_string ("0.0.3" )]
295+
296+ # With failover disabled
297+ node_ids = response ._resolve_node_account_ids (mock_client )
298+ assert node_ids == [AccountId .from_string ("0.0.3" )]
299+
300+
301+ def test_resolve_node_account_ids_with_transaction_nodes (mock_client ):
302+ """Test that transaction nodes are used when receipt failover is enabled."""
303+ response = TransactionResponse ()
304+ response .node_id = AccountId .from_string ("0.0.3" )
305+ response ._transaction_node_ids = [AccountId .from_string ("0.0.3" ), AccountId .from_string ("0.0.4" )]
306+
307+ mock_client .set_allow_receipt_node_failover (True )
308+ node_ids = response ._resolve_node_account_ids (mock_client )
309+ assert node_ids == [AccountId .from_string ("0.0.3" ), AccountId .from_string ("0.0.4" )]
310+
311+
312+ def test_resolve_node_account_ids_uses_client_nodes_when_transaction_nodes_unavailable (mock_client ):
313+ """Test that client nodes are used when transaction nodes are unavailable."""
314+ response = TransactionResponse ()
315+ response .node_id = AccountId .from_string ("0.0.3" )
316+ response ._transaction_node_ids = []
317+
318+ mock_client .set_allow_receipt_node_failover (True )
319+ node_ids = response ._resolve_node_account_ids (mock_client )
320+
321+ assert node_ids == mock_client .get_node_account_ids ()
322+
323+
256324def test_default_receipt_query_is_pinned_to_submitting_node (mock_client ):
257325 """Test that receipt queries use only the submitting node by default."""
258326 node_id = AccountId .from_string ("0.0.4" )
@@ -271,7 +339,7 @@ def test_default_receipt_query_is_pinned_to_submitting_node(mock_client):
271339 assert query .node_account_ids == [node_id ]
272340
273341 # With failover disabled
274- query = response .get_receipt_query (mock_client )
342+ query = response .get_receipt_query (client = mock_client )
275343 assert isinstance (query , TransactionGetReceiptQuery )
276344 assert query .node_account_ids == [node_id ]
277345
0 commit comments