@@ -359,3 +359,68 @@ def test_topic_update_transaction_with_all_fields(topic_id):
359359
360360 # Verify the receipt contains the expected values
361361 assert receipt .status == ResponseCode .SUCCESS
362+
363+
364+ def test_topic_memo_and_transaction_memo_independent_in_protobuf (
365+ mock_account_ids ,
366+ topic_id ,
367+ ):
368+ """Topic and transaction memos serialize independently."""
369+
370+ _ , _ , node_account_id , _ , _ = mock_account_ids
371+
372+ tx = TopicUpdateTransaction (
373+ topic_id = topic_id ,
374+ memo = "my topic memo" ,
375+ )
376+
377+ tx .operator_account_id = AccountId (0 , 0 , 2 )
378+ tx .node_account_id = node_account_id
379+
380+ tx .set_transaction_memo ("some unrelated audit note" )
381+
382+ body = tx .build_transaction_body ()
383+
384+ assert body .memo == "some unrelated audit note"
385+ assert body .consensusUpdateTopic .memo .value == "my topic memo"
386+
387+
388+ def test_set_memo_updates_topic_memo_only ():
389+ """Verify set_memo() only updates the topic memo."""
390+ tx = TopicUpdateTransaction ()
391+ tx .set_transaction_memo ("audit note" )
392+ tx .set_memo ("new topic memo" )
393+
394+ assert tx .topic_memo == "new topic memo"
395+ assert tx .memo == "audit note"
396+
397+
398+ def test_topic_memo_serialization_distinguishes_unset_and_empty (
399+ mock_account_ids ,
400+ topic_id ,
401+ ):
402+ """Unset and explicit empty topic memos serialize differently."""
403+ _ , _ , node_account_id , _ , _ = mock_account_ids
404+
405+ tx = TopicUpdateTransaction (topic_id = topic_id )
406+ tx .operator_account_id = AccountId (0 , 0 , 2 )
407+ tx .node_account_id = node_account_id
408+
409+ body = tx .build_transaction_body ().consensusUpdateTopic
410+ assert not body .HasField ("memo" )
411+
412+ tx = TopicUpdateTransaction (topic_id = topic_id , memo = "" )
413+ tx .operator_account_id = AccountId (0 , 0 , 2 )
414+ tx .node_account_id = node_account_id
415+
416+ body = tx .build_transaction_body ().consensusUpdateTopic
417+ assert body .HasField ("memo" )
418+ assert body .memo .value == ""
419+
420+ tx = TopicUpdateTransaction (topic_id = topic_id , memo = "hello" )
421+ tx .operator_account_id = AccountId (0 , 0 , 2 )
422+ tx .node_account_id = node_account_id
423+
424+ body = tx .build_transaction_body ().consensusUpdateTopic
425+ assert body .HasField ("memo" )
426+ assert body .memo .value == "hello"
0 commit comments