Skip to content

Commit 31ddd71

Browse files
committed
chore: neat pick
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 75650a0 commit 31ddd71

7 files changed

Lines changed: 36 additions & 32 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
@@ -259,13 +259,7 @@ def freeze_with(self, client: "Client") -> "TopicMessageSubmitTransaction":
259259
if self._transaction_body_bytes:
260260
return self
261261

262-
if self.transaction_id is None:
263-
if client is None:
264-
raise ValueError(
265-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
266-
)
267-
268-
self.transaction_id = client.generate_transaction_id()
262+
self._resolve_transaction_id(client)
269263

270264
if not self._transaction_ids:
271265
base_timestamp = self.transaction_id.valid_start

src/hiero_sdk_python/file/file_append_transaction.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,7 @@ def freeze_with(self, client: "Client") -> FileAppendTransaction:
285285
return self
286286

287287

288-
if self.transaction_id is None:
289-
if client is None:
290-
raise ValueError(
291-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
292-
)
293-
294-
self.transaction_id = client.generate_transaction_id()
288+
self._resolve_transaction_id(client)
295289

296290
# Generate transaction IDs for all chunks
297291
if not self._transaction_ids:

src/hiero_sdk_python/node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def _get_channel(self):
124124
if self._root_certificates:
125125
# Use the certificate that is provided
126126
self._node_pem_cert = self._root_certificates
127+
print("node cert ", self._node_pem_cert)
128+
127129
else:
128130
# Fetch pem_cert for the node
129131
self._node_pem_cert = self._fetch_server_certificate_pem()

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,24 @@ def _to_proto(self):
239239
return transaction_pb2.Transaction(
240240
signedTransactionBytes=signed_transaction.SerializeToString()
241241
)
242+
243+
def _resolve_transaction_id(self, client: "Client"):
244+
if self.transaction_id is not None:
245+
return
246+
247+
if client is not None:
248+
operator_account_id = client.operator_account_id
249+
if operator_account_id is not None:
250+
self.transaction_id = client.generate_transaction_id()
251+
else:
252+
raise ValueError(
253+
"Client must have an operator_account or transactionId must be set."
254+
)
255+
else:
256+
raise ValueError(
257+
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
258+
)
259+
242260

243261
def freeze(self):
244262
"""
@@ -277,19 +295,7 @@ def freeze_with(self, client: "Client"):
277295
return self
278296

279297
# Check transaction_id and node id to be set when using freeze()
280-
if self.transaction_id is None:
281-
if client is not None:
282-
operator_account_id = client.operator_account_id
283-
if operator_account_id is not None:
284-
self.transaction_id = client.generate_transaction_id()
285-
else:
286-
raise ValueError(
287-
"Client must have an operator_account or transactionId must be set."
288-
)
289-
else:
290-
raise ValueError(
291-
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
292-
)
298+
self._resolve_transaction_id(client)
293299

294300

295301
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
@@ -308,7 +308,7 @@ def test_integration_file_append_transaction_method_chaining(env):
308308
assert append_receipt.status == ResponseCode.SUCCESS
309309

310310
@pytest.mark.integration
311-
def test_file_append_chuck_transaction_can_execute_with_manual_freeze(env):
311+
def test_file_append_chunk_transaction_can_execute_with_manual_freeze(env):
312312
"""Test file append transaction can execute with manual freeze."""
313313
create_receipt = (
314314
FileCreateTransaction()
@@ -323,7 +323,7 @@ def test_file_append_chuck_transaction_can_execute_with_manual_freeze(env):
323323
file_contents = FileContentsQuery().set_file_id(file_id).execute(env.client)
324324
assert file_contents == b""
325325

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

328328
tx = (
329329
FileAppendTransaction()

tests/unit/mock_server.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,17 @@ def close(self):
126126
self.server.stop(0)
127127

128128

129+
_USED_PORTS = set()
130+
129131
def _find_free_port():
130132
"""Find a free port on localhost."""
131133
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
132134
s.bind(("", 0))
133-
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
134135
port = s.getsockname()[1]
135136

136137
# If we get the tls port 50212 port skip it
137138
if port == 50212:
138-
return port + 1
139+
return _find_free_port()
139140

140141
return port
141142

@@ -177,10 +178,15 @@ def mock_hedera_servers(response_sequences):
177178

178179
# Create network and client
179180
network = Network(nodes=nodes)
181+
network.set_transport_security(False)
182+
network.set_verify_certificates(False)
180183
client = Client(network)
181184

185+
# Force non-tls channel
182186
for node in client.network.nodes:
183-
node._address = node._address._to_insecure()
187+
node._address._is_transport_security = lambda: False
188+
node._set_verify_certificates(False)
189+
node._close()
184190

185191
client.logger.set_level(LogLevel.DISABLED)
186192
# Set the operator

0 commit comments

Comments
 (0)