Skip to content

Commit c60399f

Browse files
committed
fix:updating file changes
Signed-off-by: Angelina <aceppaluni@gmail.com>
1 parent eeaeed4 commit c60399f

File tree

5 files changed

+34
-41
lines changed

5 files changed

+34
-41
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ jobs:
2222

2323
steps:
2424
- name: Harden the runner (Audit all outbound calls)
25-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
25+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
2626
with:
2727
egress-policy: audit
2828

2929
- name: Checkout repository
30-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
30+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3131

3232
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
33+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636
cache: 'pip'
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: Prepare Hiero Solo
5151
id: solo
52-
uses: hiero-ledger/hiero-solo-action@fbca3e7a99ce9aa8a250563a81187abe115e0dad # v0.15.0
52+
uses: hiero-ledger/hiero-solo-action@dd0048139ef1e40fd6067f01bf94eb42a67294f4 # v0.15.0
5353
with:
5454
installMirrorNode: true
5555

@@ -105,7 +105,14 @@ jobs:
105105
- name: Fail workflow if any tests failed
106106
shell: bash
107107
run: |
108-
if [ "${{ steps.integration.outputs.integration_failed }}" != "0" ] || [ "${{ steps.unit.outputs.unit_failed }}" != "0" ]; then
108+
integration_failed="${{ steps.integration.outputs.integration_failed }}"
109+
unit_failed="${{ steps.unit.outputs.unit_failed }}"
110+
111+
# Default to 0 if empty
112+
integration_failed="${integration_failed:-0}"
113+
unit_failed="${unit_failed:-0}"
114+
115+
if [ "$integration_failed" != "0" ] || [ "$unit_failed" != "0" ]; then
109116
echo "❌ Some tests failed. Failing workflow."
110117
exit 1
111118
else

src/hiero_sdk_python/executable.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,4 @@ def _execute_method(method, proto_request):
306306
return method.transaction(proto_request)
307307
elif method.query is not None:
308308
return method.query(proto_request)
309-
raise Exception("No method to execute")
310-
309+
raise Exception("No method to execute")

src/hiero_sdk_python/query/query.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ def _before_execute(self, client: Client) -> None:
107107
"""
108108
self.operator = self.operator or client.operator
109109

110-
if not getattr(self, "node_account_ids", None):
111-
self.node_account_ids = client.get_node_account_ids()
112-
113110
# If no payment amount was specified and payment is required for this query,
114111
# get the cost from the network and set it as the payment amount
115112
if self.payment_amount is None and self._is_payment_required():
@@ -377,3 +374,4 @@ def _is_payment_required(self) -> bool:
377374
bool: True if payment is required, False otherwise
378375
"""
379376
return True
377+

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
from hiero_sdk_python.crypto.private_key import PrivateKey
1010
from hiero_sdk_python.exceptions import PrecheckError
1111
from hiero_sdk_python.executable import _Executable, _ExecutionState
12-
from hiero_sdk_python.hapi.services import (basic_types_pb2, transaction_pb2, transaction_contents_pb2)
12+
from hiero_sdk_python.hapi.services import (basic_types_pb2, transaction_pb2, transaction_contents_pb2, transaction_pb2)
1313
from hiero_sdk_python.hapi.services.schedulable_transaction_body_pb2 import SchedulableTransactionBody
1414
from hiero_sdk_python.hapi.services.transaction_response_pb2 import (TransactionResponse as TransactionResponseProto)
15-
from hiero_sdk_python.hbar import Hbar
1615
from hiero_sdk_python.response_code import ResponseCode
1716
from hiero_sdk_python.transaction.transaction_id import TransactionId
1817
from hiero_sdk_python.transaction.transaction_response import TransactionResponse
@@ -62,12 +61,9 @@ def __init__(self) -> None:
6261
# This allows us to maintain the signatures for each unique transaction
6362
# and ensures that the correct signatures are used when submitting transactions
6463
self._signature_map: dict[bytes, basic_types_pb2.SignatureMap] = {}
65-
# changed from int: 2_000_000 to Hbar: 0.02
66-
self._default_transaction_fee = Hbar(0.02)
67-
self.operator_account_id = None
64+
self._default_transaction_fee = 2_000_000
65+
self.operator_account_id = None
6866
self.batch_key: Optional[PrivateKey] = None
69-
self.node_account_ids: Optional[List[AccountId]] = None
70-
self._used_node_account_id: Optional[AccountId] = None
7167

7268
def _make_request(self):
7369
"""
@@ -423,11 +419,7 @@ def build_base_transaction_body(self) -> transaction_pb2.TransactionBody:
423419
transaction_body.transactionID.CopyFrom(transaction_id_proto)
424420
transaction_body.nodeAccountID.CopyFrom(self.node_account_id._to_proto())
425421

426-
fee = self.transaction_fee or self._default_transaction_fee
427-
if hasattr(fee, "to_tinybars"):
428-
transaction_body.transactionFee = int(fee.to_tinybars())
429-
else:
430-
transaction_body.transactionFee = int(fee)
422+
transaction_body.transactionFee = self.transaction_fee or self._default_transaction_fee
431423

432424
transaction_body.transactionValidDuration.seconds = self.transaction_valid_duration
433425
transaction_body.generateRecord = self.generate_record
@@ -449,13 +441,9 @@ def build_base_scheduled_body(self) -> SchedulableTransactionBody:
449441
The protobuf SchedulableTransactionBody message with common fields set.
450442
"""
451443
schedulable_body = SchedulableTransactionBody()
452-
453-
fee = self.transaction_fee or self._default_transaction_fee
454-
if hasattr(fee, "to_tinybars"):
455-
schedulable_body.transactionFee = int(fee.to_tinybars())
456-
else:
457-
schedulable_body.transactionFee = int(fee)
458-
444+
schedulable_body.transactionFee = (
445+
self.transaction_fee or self._default_transaction_fee
446+
)
459447
schedulable_body.memo = self.memo
460448
custom_fee_limits = [custom_fee._to_proto() for custom_fee in self.custom_fee_limits]
461449
schedulable_body.max_custom_fees.extend(custom_fee_limits)

tests/unit/test_executable.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_retry_success_before_max_attempts():
4646
# First server gives 2 BUSY responses then OK on the 3rd try
4747
response_sequences = [[busy_response, busy_response, ok_response, receipt_response]]
4848

49-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
49+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
5050
# Configure client to allow 3 attempts - should succeed on the last try
5151
client.max_attempts = 3
5252

@@ -70,7 +70,7 @@ def test_retry_failure_after_max_attempts():
7070

7171
response_sequences = [[busy_response, busy_response]]
7272

73-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
73+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
7474
client.max_attempts = 2
7575

7676
transaction = (
@@ -112,7 +112,7 @@ def test_node_switching_after_single_grpc_error():
112112
[error],
113113
]
114114

115-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
115+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
116116
transaction = (
117117
AccountCreateTransaction()
118118
.set_key(PrivateKey.generate().public_key())
@@ -149,7 +149,7 @@ def test_node_switching_after_multiple_grpc_errors():
149149
[ok_response, receipt_response],
150150
]
151151

152-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
152+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
153153
transaction = (
154154
AccountCreateTransaction()
155155
.set_key(PrivateKey.generate().public_key())
@@ -185,7 +185,7 @@ def test_transaction_with_expired_error_not_retried():
185185
[error_response]
186186
]
187187

188-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
188+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
189189
transaction = (
190190
AccountCreateTransaction()
191191
.set_key(PrivateKey.generate().public_key())
@@ -216,7 +216,7 @@ def test_transaction_with_fatal_error_not_retried():
216216
[error_response]
217217
]
218218

219-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
219+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
220220
transaction = (
221221
AccountCreateTransaction()
222222
.set_key(PrivateKey.generate().public_key())
@@ -248,7 +248,7 @@ def test_exponential_backoff_retry():
248248
response_sequences = [[busy_response, busy_response, busy_response, ok_response, receipt_response]]
249249

250250
# Use a mock for time.sleep to capture the delay values
251-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep') as mock_sleep:
251+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep') as mock_sleep:
252252
client.max_attempts = 5
253253

254254
transaction = (
@@ -288,7 +288,7 @@ def test_retriable_error_does_not_switch_node():
288288
)
289289
)
290290
response_sequences = [[busy_response, ok_response, receipt_response]]
291-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
291+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
292292
transaction = (
293293
AccountCreateTransaction()
294294
.set_key(PrivateKey.generate().public_key())
@@ -333,7 +333,7 @@ def test_topic_create_transaction_retry_on_busy():
333333
[busy_response, ok_response, receipt_response],
334334
]
335335

336-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep') as mock_sleep:
336+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep') as mock_sleep:
337337
client.max_attempts = 3
338338

339339
tx = (
@@ -367,7 +367,7 @@ def test_topic_create_transaction_fails_on_nonretriable_error():
367367
[error_response],
368368
]
369369

370-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
370+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
371371
tx = (
372372
TopicCreateTransaction()
373373
.set_memo("Test with error")
@@ -400,7 +400,7 @@ def test_transaction_node_switching_body_bytes():
400400
[ok_response, receipt_response],
401401
]
402402

403-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep'):
403+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep'):
404404
# We set the current node to 0
405405
client.network._node_index = 0
406406
client.network.current_node = client.network.nodes[0]
@@ -467,8 +467,9 @@ def test_query_retry_on_busy():
467467
[ok_response],
468468
]
469469

470-
with mock_hedera_servers(response_sequences) as client, patch('time.sleep') as mock_sleep:
470+
with mock_hedera_servers(response_sequences) as client, patch('hiero_sdk_python.executable.time.sleep') as mock_sleep:
471471
# We set the current node to the first node so we are sure it will return BUSY response
472+
client.network._node_index = 0
472473
client.network.current_node = client.network.nodes[0]
473474

474475
query = CryptoGetAccountBalanceQuery()

0 commit comments

Comments
 (0)