Skip to content

Commit c882d60

Browse files
committed
chore: neat pick
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 267ef6e commit c882d60

7 files changed

Lines changed: 37 additions & 24 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ dependencies = [
2121
"pycryptodome>=3.18.0,<4",
2222
"eth-abi>=5.1.0,<6",
2323
"python-dotenv>=1.2.1,<3",
24+
"pytest-repeat>=0.9.4",
25+
"pytest-xdist>=3.8.0",
2426
]
2527
classifiers = [
2628
"Development Status :: 2 - Pre-Alpha",

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,7 @@ def freeze_with(self, client: Client) -> TopicMessageSubmitTransaction:
253253
if self._transaction_body_bytes:
254254
return self
255255

256-
if self.transaction_id is None:
257-
if client is None:
258-
raise ValueError(
259-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
260-
)
261-
262-
self.transaction_id = client.generate_transaction_id()
256+
self._resolve_transaction_id(client)
263257

264258
if not self._transaction_ids:
265259
base_timestamp = self.transaction_id.valid_start

src/hiero_sdk_python/file/file_append_transaction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ def freeze_with(self, client: Client) -> FileAppendTransaction:
295295

296296
self.transaction_id = client.generate_transaction_id()
297297

298+
299+
self._resolve_transaction_id(client)
300+
298301
# Generate transaction IDs for all chunks
299302
if not self._transaction_ids:
300303
base_timestamp = self.transaction_id.valid_start

src/hiero_sdk_python/node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ 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+
print("node cert ", self._node_pem_cert)
130+
129131
else:
130132
# Fetch pem_cert for the node
131133
self._node_pem_cert = self._fetch_server_certificate_pem()

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +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())
229+
230+
return transaction_pb2.Transaction(
231+
signedTransactionBytes=signed_transaction.SerializeToString()
232+
)
233+
234+
def _resolve_transaction_id(self, client: "Client"):
235+
if self.transaction_id is not None:
236+
return
237+
238+
if client is not None:
239+
operator_account_id = client.operator_account_id
240+
if operator_account_id is not None:
241+
self.transaction_id = client.generate_transaction_id()
242+
else:
243+
raise ValueError(
244+
"Client must have an operator_account or transactionId must be set."
245+
)
246+
else:
247+
raise ValueError(
248+
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
249+
)
250+
230251

231252
def freeze(self):
232253
"""
@@ -266,19 +287,7 @@ def freeze_with(self, client: "Client"):
266287

267288

268289
# Check transaction_id and node id to be set when using freeze()
269-
if self.transaction_id is None:
270-
if client is not None:
271-
operator_account_id = client.operator_account_id
272-
if operator_account_id is not None:
273-
self.transaction_id = client.generate_transaction_id()
274-
else:
275-
raise ValueError(
276-
"Client must have an operator_account or transactionId must be set."
277-
)
278-
else:
279-
raise ValueError(
280-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
281-
)
290+
self._resolve_transaction_id(client)
282291

283292

284293
if self.node_account_id is None and len(self.node_account_ids) == 0:

tests/integration/file_append_transaction_e2e_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def test_integration_file_append_transaction_method_chaining(env):
292292
assert append_receipt.status == ResponseCode.SUCCESS
293293

294294
@pytest.mark.integration
295-
def test_file_append_chuck_transaction_can_execute_with_manual_freeze(env):
295+
def test_file_append_chunk_transaction_can_execute_with_manual_freeze(env):
296296
"""Test file append transaction can execute with manual freeze."""
297297
create_receipt = (
298298
FileCreateTransaction()
@@ -307,7 +307,7 @@ def test_file_append_chuck_transaction_can_execute_with_manual_freeze(env):
307307
file_contents = FileContentsQuery().set_file_id(file_id).execute(env.client)
308308
assert file_contents == b""
309309

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

312312
tx = (
313313
FileAppendTransaction()

tests/unit/mock_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ def mock_hedera_servers(response_sequences):
181181

182182
client = Client(network)
183183

184+
# Force non-tls channel
184185
for node in client.network.nodes:
185-
node._address = node._address._to_insecure()
186+
node._address._is_transport_security = lambda: False
187+
node._set_verify_certificates(False)
188+
node._close()
186189

187190
client.logger.set_level(LogLevel.DISABLED)
188191
# Set the operator

0 commit comments

Comments
 (0)