Skip to content

Commit 3297643

Browse files
committed
chore: added test for the schedule()
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 1eb9043 commit 3297643

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/unit/file_append_transaction_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,3 +524,15 @@ def test_file_append_transaction_create_proper_content(file_id, mock_client):
524524

525525
assert body.fileAppend.contents.decode("utf-8") == content
526526
assert body.transactionID == transaction_id._to_proto()
527+
528+
529+
def test_schedule_transaction_rejects_message_exceeding_chunk_size(file_id):
530+
"""Test that scheduling fails when the message exceeds the chunk size."""
531+
tx = FileAppendTransaction().set_file_id(file_id).set_chunk_size(10).set_contents(bytes(20))
532+
533+
with pytest.raises(
534+
RuntimeError,
535+
match=f"Cannot schedule FileAppendTransaction because the contents "
536+
f"exceeds the maximum chunk size of {tx.chunk_size} bytes",
537+
):
538+
tx.schedule()

tests/unit/topic_message_submit_transaction_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,15 @@ def test_message_submit_transaction_create_proper_content(topic_id, mock_client)
735735
assert not proto.HasField("chunkInfo")
736736
assert body.consensusSubmitMessage.message.decode("utf-8") == message
737737
assert body.transactionID == transaction_id._to_proto()
738+
739+
740+
def test_schedule_transaction_rejects_message_exceeding_chunk_size(topic_id):
741+
"""Test that scheduling fails when the message exceeds the chunk size."""
742+
tx = TopicMessageSubmitTransaction().set_topic_id(topic_id).set_chunk_size(10).set_message(bytes(20))
743+
744+
with pytest.raises(
745+
RuntimeError,
746+
match=f"Cannot schedule TopicMessageSubmitTransaction because the message "
747+
f"exceeds the maximum chunk size of {tx.chunk_size} bytes",
748+
):
749+
tx.schedule()

0 commit comments

Comments
 (0)