Skip to content

Commit aacd897

Browse files
authored
feat: add clear_custom_fee_limits() to TopicMessageSubmitTransaction (#2483)
Signed-off-by: iron-prog <dt915725@gmail.com>
1 parent 8b8bdaa commit aacd897

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ def add_custom_fee_limit(self, custom_fee_limit: CustomFeeLimit) -> TopicMessage
162162
self.custom_fee_limits.append(custom_fee_limit)
163163
return self
164164

165+
def clear_custom_fee_limits(self) -> TopicMessageSubmitTransaction:
166+
"""
167+
Clears all previously configured custom fee limits for the message submission.
168+
169+
Returns:
170+
TopicMessageSubmitTransaction: This transaction instance (for chaining).
171+
"""
172+
self._require_not_frozen()
173+
self.custom_fee_limits = []
174+
return self
175+
165176
def _build_proto_body(self) -> consensus_submit_message_pb2.ConsensusSubmitMessageTransactionBody:
166177
"""
167178
Returns the protobuf body for the topic message submit transaction.

tests/unit/topic_message_submit_transaction_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ def test_constructor_and_setters(topic_id, message, custom_fee_limit):
9999
assert tx_default.custom_fee_limits[0] == custom_fee_limit
100100
assert result is tx_default
101101

102+
# Test clear_custom_fee_limits
103+
result = tx_default.clear_custom_fee_limits()
104+
assert tx_default.custom_fee_limits == []
105+
assert result is tx_default
106+
102107

103108
def test_set_methods_require_not_frozen(mock_client, topic_id, message, custom_fee_limit):
104109
"""Test that setter methods raise exception when transaction is frozen."""
@@ -122,6 +127,16 @@ def test_set_methods_require_not_frozen(mock_client, topic_id, message, custom_f
122127
getattr(tx, method_name)(value)
123128

124129

130+
def test_clear_custom_fee_limits_requires_not_frozen(mock_client, topic_id, message, custom_fee_limit):
131+
"""Test that clear_custom_fee_limits() raises when the transaction is frozen."""
132+
tx = TopicMessageSubmitTransaction(topic_id=topic_id, message=message)
133+
tx.add_custom_fee_limit(custom_fee_limit)
134+
tx.freeze_with(mock_client)
135+
136+
with pytest.raises(Exception, match="Transaction is immutable; it has been frozen"):
137+
tx.clear_custom_fee_limits()
138+
139+
125140
def test_method_chaining(topic_id, message, custom_fee_limit):
126141
"""Test method chaining functionality."""
127142
tx = TopicMessageSubmitTransaction()
@@ -144,6 +159,10 @@ def test_method_chaining(topic_id, message, custom_fee_limit):
144159
assert tx.chunk_size == chunk_size
145160
assert tx.max_chunks == max_chunks
146161

162+
result = tx.clear_custom_fee_limits()
163+
assert result is tx
164+
assert tx.custom_fee_limits == []
165+
147166

148167
def test_get_method():
149168
"""Test retrieving the gRPC method for the transaction."""

0 commit comments

Comments
 (0)