Skip to content

Commit c8503a6

Browse files
committed
chore: fix rebase
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 66269ef commit c8503a6

9 files changed

Lines changed: 36 additions & 98 deletions

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Literal, overload
55

66
from hiero_sdk_python.channels import _Channel
7-
from typing import List, Literal, Optional, overload
87
from hiero_sdk_python.client.client import Client
98
from hiero_sdk_python.consensus.topic_id import TopicId
109
from hiero_sdk_python.crypto.private_key import PrivateKey
@@ -404,7 +403,7 @@ def sign(self, private_key: PrivateKey):
404403

405404
super().sign(private_key)
406405
return self
407-
406+
408407
@property
409408
def body_size_all_chunks(self) -> list[int]:
410409
"""Returns an array of body sizes for transactions with multiple chunks."""
@@ -416,8 +415,7 @@ def body_size_all_chunks(self) -> list[int]:
416415
for transaction_id in self._transaction_ids:
417416
self.transaction_id = transaction_id
418417
sizes.append(self.body_size)
419-
418+
420419
self._current_index = original_index
421420
self.transaction_id = original_transaction_id
422421
return sizes
423-

src/hiero_sdk_python/file/file_append_transaction.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import math
1717
from typing import TYPE_CHECKING, Any, Literal, overload
1818

19-
from typing import TYPE_CHECKING, Any, List, Literal, Optional, overload
2019
from hiero_sdk_python.file.file_id import FileId
2120
from hiero_sdk_python.hapi.services import file_append_pb2, timestamp_pb2
2221
from hiero_sdk_python.hapi.services.schedulable_transaction_body_pb2 import (
@@ -30,10 +29,8 @@
3029
# Use TYPE_CHECKING to avoid circular import errors
3130
if TYPE_CHECKING:
3231
from hiero_sdk_python.channels import _Channel
33-
from hiero_sdk_python.client import Client
32+
from hiero_sdk_python.client.client import Client
3433
from hiero_sdk_python.crypto.private_key import PrivateKey
35-
36-
from hiero_sdk_python.channels import _Channel
3734
from hiero_sdk_python.executable import _Method
3835
from hiero_sdk_python.transaction.transaction import TransactionReceipt
3936
from hiero_sdk_python.transaction.transaction_response import TransactionResponse
@@ -289,35 +286,12 @@ def freeze_with(self, client: Client) -> FileAppendTransaction:
289286
if self._transaction_body_bytes:
290287
return self
291288

292-
if self.transaction_id is None:
293-
if client is None:
294-
raise ValueError(
295-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
296-
)
297-
298-
self.transaction_id = client.generate_transaction_id()
299-
300-
301289
self._resolve_transaction_id(client)
302290

303291
# Generate transaction IDs for all chunks
304292
if not self._transaction_ids:
305293
base_timestamp = self.transaction_id.valid_start
306294

307-
for i in range(self.get_required_chunks()):
308-
if i == 0:
309-
# First chunk uses the original transaction ID
310-
chunk_transaction_id = self.transaction_id
311-
else:
312-
# Subsequent chunks get incremented timestamps
313-
# Add i nanoseconds to space out chunks
314-
chunk_valid_start = timestamp_pb2.Timestamp(
315-
seconds=base_timestamp.seconds, nanos=base_timestamp.nanos + i
316-
)
317-
chunk_transaction_id = TransactionId(
318-
account_id=self.transaction_id.account_id, valid_start=chunk_valid_start
319-
)
320-
self._transaction_ids.append(chunk_transaction_id)
321295
for i in range(self.get_required_chunks()):
322296
if i == 0:
323297
# First chunk uses the original transaction ID
@@ -326,12 +300,10 @@ def freeze_with(self, client: Client) -> FileAppendTransaction:
326300
# Subsequent chunks get incremented timestamps
327301
# Add i nanoseconds to space out chunks
328302
chunk_valid_start = timestamp_pb2.Timestamp(
329-
seconds=base_timestamp.seconds,
330-
nanos=base_timestamp.nanos + i
303+
seconds=base_timestamp.seconds, nanos=base_timestamp.nanos + i
331304
)
332305
chunk_transaction_id = TransactionId(
333-
account_id=self.transaction_id.account_id,
334-
valid_start=chunk_valid_start
306+
account_id=self.transaction_id.account_id, valid_start=chunk_valid_start
335307
)
336308

337309
self._transaction_ids.append(chunk_transaction_id)
@@ -476,7 +448,6 @@ def sign(self, private_key: PrivateKey) -> FileAppendTransaction:
476448
super().sign(private_key)
477449
return self
478450

479-
480451
@property
481452
def body_size_all_chunks(self) -> list[int]:
482453
"""Returns an array of body sizes for transactions with multiple chunks."""
@@ -488,8 +459,7 @@ def body_size_all_chunks(self) -> list[int]:
488459
for transaction_id in self._transaction_ids:
489460
self.transaction_id = transaction_id
490461
sizes.append(self.body_size)
491-
462+
492463
self._current_chunk_index = original_index
493464
self.transaction_id = original_transaction_id
494465
return sizes
495-

src/hiero_sdk_python/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _get_channel(self):
126126
if self._root_certificates:
127127
# Use the certificate that is provided
128128
self._node_pem_cert = self._root_certificates
129-
129+
130130
else:
131131
# Fetch pem_cert for the node
132132
self._node_pem_cert = self._fetch_server_certificate_pem()

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -226,34 +226,28 @@ def _to_proto(self):
226226

227227
signed_transaction = transaction_contents_pb2.SignedTransaction(bodyBytes=body_bytes, sigMap=sig_map)
228228

229+
return transaction_pb2.Transaction(signedTransactionBytes=signed_transaction.SerializeToString())
229230

230-
return transaction_pb2.Transaction(
231-
signedTransactionBytes=signed_transaction.SerializeToString()
232-
)
233-
234-
def _resolve_transaction_id(self, client: "Client"):
231+
def _resolve_transaction_id(self, client: Client):
235232
if self.transaction_id is not None:
236233
return
237-
234+
238235
if client is not None:
239236
operator_account_id = client.operator_account_id
240237
if operator_account_id is not None:
241238
self.transaction_id = client.generate_transaction_id()
242239
else:
243-
raise ValueError(
244-
"Client must have an operator_account or transactionId must be set."
245-
)
240+
raise ValueError("Client must have an operator_account or transactionId must be set.")
246241
else:
247242
raise ValueError(
248243
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
249244
)
250-
251-
def _resolve_node_ids(self, client: "Client"):
252-
if self.node_account_id is None and len(self.node_account_ids) == 0:
253-
if client is None:
254-
raise ValueError(
255-
"Node account ID must be set before freezing. Use freeze_with(client) or manually set node_account_ids."
256-
)
245+
246+
def _resolve_node_ids(self, client: Client):
247+
if self.node_account_id is None and len(self.node_account_ids) == 0 and client is None:
248+
raise ValueError(
249+
"Node account ID must be set before freezing. Use freeze_with(client) or manually set node_account_ids."
250+
)
257251

258252
def freeze(self):
259253
"""
@@ -275,7 +269,7 @@ def freeze(self):
275269
"""
276270
return self.freeze_with(None)
277271

278-
def freeze_with(self, client: "Client"):
272+
def freeze_with(self, client: Client):
279273
"""
280274
Freezes the transaction by building the transaction body and setting necessary IDs.
281275
@@ -291,13 +285,11 @@ def freeze_with(self, client: "Client"):
291285
if self._transaction_body_bytes:
292286
return self
293287

294-
295288
# Check transaction_id and node id to be set when using freeze()
296289
self._resolve_transaction_id(client)
297290

298-
299291
self._resolve_node_ids(client)
300-
292+
301293
# We iterate through every node in the client's network
302294
# For each node, set the node_account_id and build the transaction body
303295
# This allows the transaction to be submitted to any node in the network
@@ -934,7 +926,7 @@ def size(self) -> int:
934926
"""Returns the total transaction size in bytes after protobuf encoding"""
935927
self._require_frozen()
936928
return self._make_request().ByteSize()
937-
929+
938930
@property
939931
def body_size(self) -> int:
940932
"""Returns just the transaction body size in bytes after encoding"""

tests/integration/file_append_transaction_e2e_test.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
from pytest import mark
55

66
from hiero_sdk_python.account.account_id import AccountId
7-
from hiero_sdk_python.file.file_create_transaction import FileCreateTransaction
87
from hiero_sdk_python.file.file_append_transaction import FileAppendTransaction
98
from hiero_sdk_python.file.file_contents_query import FileContentsQuery
109
from hiero_sdk_python.file.file_create_transaction import FileCreateTransaction
1110
from hiero_sdk_python.response_code import ResponseCode
12-
13-
from hiero_sdk_python.hbar import Hbar
14-
from hiero_sdk_python.exceptions import PrecheckError
1511
from hiero_sdk_python.transaction.transaction_id import TransactionId
16-
from tests.integration.utils import env, IntegrationTestEnv
12+
1713

1814
# Generate big contents for chunking tests - similar to JavaScript bigContents
1915
BIG_CONTENTS = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " * 250 # ~13,750 characters
@@ -289,7 +285,8 @@ def test_integration_file_append_transaction_method_chaining(env):
289285

290286
append_receipt = append_tx.execute(env.client)
291287
assert append_receipt.status == ResponseCode.SUCCESS
292-
assert append_receipt.status == ResponseCode.SUCCESS
288+
assert append_receipt.status == ResponseCode.SUCCESS
289+
293290

294291
@pytest.mark.integration
295292
def test_file_append_chunk_transaction_can_execute_with_manual_freeze(env):
@@ -307,22 +304,22 @@ def test_file_append_chunk_transaction_can_execute_with_manual_freeze(env):
307304
file_contents = FileContentsQuery().set_file_id(file_id).execute(env.client)
308305
assert file_contents == b""
309306

310-
content = "A" * (4000) # content with (4000/1024) bytes ie approx 4 chunks
307+
content = "A" * (4000) # content with (4000/1024) bytes ie approx 4 chunks
311308

312309
tx = (
313310
FileAppendTransaction()
314311
.set_file_id(file_id)
315312
.set_chunk_size(1024)
316313
.set_contents(content)
317314
.set_transaction_id(TransactionId.generate(env.client.operator_account_id))
318-
.set_node_account_id(AccountId(0,0,3))
315+
.set_node_account_id(AccountId(0, 0, 3))
319316
.freeze()
320317
)
321318

322319
tx.sign(env.client.operator_private_key)
323320

324321
receipt = tx.execute(env.client)
325-
322+
326323
assert receipt.status == ResponseCode.SUCCESS
327324

328325
file_contents = FileContentsQuery().set_file_id(file_id).execute(env.client)

tests/integration/topic_message_submit_transaction_e2e_test.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from hiero_sdk_python.response_code import ResponseCode
2020
from hiero_sdk_python.tokens.custom_fixed_fee import CustomFixedFee
2121
from hiero_sdk_python.transaction.custom_fee_limit import CustomFeeLimit
22-
2322
from hiero_sdk_python.transaction.transaction_id import TransactionId
2423

24+
2525
def create_topic(client, admin_key=None, submit_key=None, custom_fees=None):
2626
"""Helper transaction for creating a topic."""
2727
tx = TopicCreateTransaction(memo="Python SDK topic")
@@ -300,32 +300,28 @@ def test_integration_topic_message_submit_transaction_fails_if_required_chunk_gr
300300
delete_topic(env.client, topic_id)
301301

302302

303-
304303
@pytest.mark.integration
305304
def test_topic_message_submit_transaction_can_submit_a_large_message_manual_freeze(env):
306305
"""Test topic message submit transaction can submit large message with manual freeze."""
307-
topic_id = create_topic(
308-
client=env.client,
309-
admin_key=env.operator_key
310-
)
306+
topic_id = create_topic(client=env.client, admin_key=env.operator_key)
311307

312308
info = TopicInfoQuery().set_topic_id(topic_id).execute(env.client)
313309
assert info.sequence_number == 0
314310

315-
message = "A" * (1024 * 14) # message with (1024 * 14) bytes ie 14 chunks
311+
message = "A" * (1024 * 14) # message with (1024 * 14) bytes ie 14 chunks
316312

317313
message_tx = (
318314
TopicMessageSubmitTransaction()
319315
.set_topic_id(topic_id)
320316
.set_message(message)
321317
.set_transaction_id(TransactionId.generate(env.client.operator_account_id))
322-
.set_node_account_id(AccountId(0,0,3))
318+
.set_node_account_id(AccountId(0, 0, 3))
323319
.freeze()
324320
)
325321

326322
message_tx.sign(env.client.operator_private_key)
327323
message_receipt = message_tx.execute(env.client)
328-
324+
329325
assert message_receipt.status == ResponseCode.SUCCESS
330326

331327
info = TopicInfoQuery().set_topic_id(topic_id).execute(env.client)

tests/unit/mock_server.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ def mock_hedera_servers(response_sequences):
181181

182182
client = Client(network)
183183

184-
# Force non-tls channel
185-
for node in client.network.nodes:
186-
node._address._is_transport_security = lambda: False
187-
node._set_verify_certificates(False)
188-
node._close()
189-
190184
client.logger.set_level(LogLevel.DISABLED)
191185
# Set the operator
192186
key = PrivateKey.generate()

tests/unit/topic_message_submit_transaction_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import pytest
88

9-
from hiero_sdk_python.account.account_id import AccountId
109
from hiero_sdk_python.consensus.topic_message_submit_transaction import TopicMessageSubmitTransaction
1110
from hiero_sdk_python.exceptions import PrecheckError, ReceiptStatusError
1211
from hiero_sdk_python.hapi.services import (
@@ -505,13 +504,10 @@ def test_topic_submit_execute_returns_failed_receipt_by_default(topic_id):
505504

506505
assert receipt.status == ResponseCode.INVALID_SIGNATURE
507506

507+
508508
def test_topic_submit_message_raises_error_on_freeze(topic_id):
509509
"""Test transaction raises error on freeze when the transaction_id and node_id not set"""
510-
tx = (
511-
TopicMessageSubmitTransaction()
512-
.set_topic_id(topic_id)
513-
.set_message("Hello Hiero")
514-
)
510+
tx = TopicMessageSubmitTransaction().set_topic_id(topic_id).set_message("Hello Hiero")
515511

516512
with pytest.raises(ValueError):
517513
tx.freeze()

tests/unit/transaction_test.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
66
from hiero_sdk_python.account.account_id import AccountId
7-
from hiero_sdk_python.consensus.topic_id import TopicId
87
from hiero_sdk_python.consensus.topic_message_submit_transaction import TopicMessageSubmitTransaction
98
from hiero_sdk_python.crypto.private_key import PrivateKey
109
from hiero_sdk_python.exceptions import ReceiptStatusError
@@ -275,9 +274,7 @@ def test_tx_with_larger_content_should_have_larger_tx_body(transaction_id, accou
275274
assert tx1.body_size < tx2.body_size
276275

277276

278-
def test_tx_without_optional_fields_should_have_smaller_tx_body(
279-
transaction_id, account_id
280-
):
277+
def test_tx_without_optional_fields_should_have_smaller_tx_body(transaction_id, account_id):
281278
"""Test transaction with without optional fields should have smaller transaction body."""
282279
key = PrivateKey.generate()
283280
tx1 = (
@@ -343,7 +340,7 @@ def test_file_append_single_chunk_tx_return_list_of_len_one(file_id, account_id,
343340
def test_message_submit_chunk_tx_should_return_list_of_body_sizes(topic_id, account_id, transaction_id):
344341
"""Test topic message submit tx should return array of body sizes for multi-chunk transaction."""
345342
chunk_size = 1024
346-
message= "a" * (chunk_size * 3)
343+
message = "a" * (chunk_size * 3)
347344

348345
tx = (
349346
TopicMessageSubmitTransaction()
@@ -377,9 +374,7 @@ def test_message_submit_single_chunk_tx_return_list_of_len_one(topic_id, account
377374
assert len(sizes) == 1
378375

379376

380-
def test_tx_with_no_content_should_return_single_body_chunk(
381-
file_id, account_id, transaction_id
382-
):
377+
def test_tx_with_no_content_should_return_single_body_chunk(file_id, account_id, transaction_id):
383378
"""Test should return single body chunk for transaction with no content."""
384379
tx = (
385380
FileAppendTransaction()

0 commit comments

Comments
 (0)