-
Notifications
You must be signed in to change notification settings - Fork 209
feat: add set_node_account_ids to the query chain #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
exploreriii
merged 5 commits into
hiero-ledger:main
from
AntonioCeppellini:1686-pin-receipt-record-queries-to-submitting-node-by-default
Feb 11, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ee1086f
feat: add set_node_account_ids to the query chain
AntonioCeppellini 5e8e71d
feat: add set_node_account_ids to the query chain
AntonioCeppellini 5bfc96a
Merge branch 'main' into 1686-pin-receipt-record-queries-to-submittin…
AntonioCeppellini c9ea62f
feat: add set_node_account_ids to the query chain
AntonioCeppellini 84378a6
Merge branch 'main' into 1686-pin-receipt-record-queries-to-submittin…
AntonioCeppellini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| """ | ||
| Tests for TransactionResponse behavior. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from hiero_sdk_python.account.account_id import AccountId | ||
| from hiero_sdk_python.response_code import ResponseCode | ||
| from hiero_sdk_python.transaction.transaction_response import TransactionResponse | ||
| from hiero_sdk_python.hapi.services import ( | ||
| response_header_pb2, | ||
| response_pb2, | ||
| transaction_get_receipt_pb2, | ||
| transaction_receipt_pb2, | ||
| ) | ||
|
|
||
| from tests.unit.mock_server import mock_hedera_servers | ||
|
|
||
| pytestmark = pytest.mark.unit | ||
|
|
||
|
|
||
| def test_transaction_response_fields(transaction_id): | ||
| """asserting response is correctly populated""" | ||
| resp = TransactionResponse() | ||
|
|
||
| # Assert public attributes exist (PRIORITY 1: protect against breaking changes) | ||
| assert hasattr(resp, 'transaction_id'), "Missing public attribute: transaction_id" | ||
| assert hasattr(resp, 'node_id'), "Missing public attribute: node_id" | ||
| assert hasattr(resp, 'hash'), "Missing public attribute: hash" | ||
| assert hasattr(resp, 'validate_status'), "Missing public attribute: validate_status" | ||
| assert hasattr(resp, 'transaction'), "Missing public attribute: transaction" | ||
|
|
||
| # Assert default values | ||
| assert resp.hash == bytes(), "Default hash should be empty bytes" | ||
manishdait marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert resp.validate_status is False, "Default validate_status should be False" | ||
| assert resp.transaction is None, "Default transaction should be None" | ||
|
|
||
| resp.transaction_id = transaction_id | ||
| resp.node_id = AccountId(0, 0, 3) | ||
|
|
||
| assert resp.transaction_id == transaction_id | ||
| assert resp.node_id == AccountId(0, 0, 3) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def test_transaction_response_get_receipt_is_pinned_to_submitting_node(transaction_id): | ||
| """ | ||
| mock_hedera_servers assigns: | ||
| - server[0] -> node 0.0.3 | ||
| - server[1] -> node 0.0.4 | ||
|
|
||
| We make node 0.0.3 return a NON-retryable precheck error, and node 0.0.4 return SUCCESS. | ||
| If TransactionResponse.get_receipt() does not pin, it will likely hit 0.0.3 and fail. | ||
| If it pins to self.node_id (0.0.4), it will succeed. | ||
| """ | ||
| bad_node_response = response_pb2.Response( | ||
| transactionGetReceipt=transaction_get_receipt_pb2.TransactionGetReceiptResponse( | ||
| header=response_header_pb2.ResponseHeader( | ||
| nodeTransactionPrecheckCode=ResponseCode.INVALID_TRANSACTION | ||
| ), | ||
| receipt=transaction_receipt_pb2.TransactionReceipt( | ||
| status=ResponseCode.UNKNOWN | ||
| ), | ||
| ) | ||
| ) | ||
|
|
||
| good_node_response = response_pb2.Response( | ||
| transactionGetReceipt=transaction_get_receipt_pb2.TransactionGetReceiptResponse( | ||
| header=response_header_pb2.ResponseHeader( | ||
| nodeTransactionPrecheckCode=ResponseCode.OK | ||
| ), | ||
| receipt=transaction_receipt_pb2.TransactionReceipt( | ||
| status=ResponseCode.SUCCESS | ||
| ), | ||
| ) | ||
| ) | ||
|
|
||
| response_sequences = [ | ||
| [bad_node_response], # node 0.0.3 | ||
| [good_node_response], # node 0.0.4 | ||
| ] | ||
|
|
||
| with mock_hedera_servers(response_sequences) as client: | ||
| resp = TransactionResponse() | ||
| resp.transaction_id = transaction_id | ||
| resp.node_id = AccountId(0, 0, 4) # submitting node (server[1]) | ||
|
|
||
| receipt = resp.get_receipt(client) | ||
|
|
||
| assert receipt.status == ResponseCode.SUCCESS | ||
manishdait marked this conversation as resolved.
Show resolved
Hide resolved
manishdait marked this conversation as resolved.
Show resolved
Hide resolved
exploreriii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.