|
23 | 23 | from hiero_sdk_python.response_code import ResponseCode |
24 | 24 | from hiero_sdk_python.tokens.custom_fixed_fee import CustomFixedFee |
25 | 25 | from hiero_sdk_python.tokens.token_id import TokenId |
| 26 | +from hiero_sdk_python.transaction.transaction_id import TransactionId |
26 | 27 | from tests.unit.mock_server import mock_hedera_servers |
27 | 28 |
|
28 | 29 |
|
@@ -574,3 +575,55 @@ def test_mixed_key_types_in_constructor(mock_account_ids): |
574 | 575 | assert transaction_body.consensusCreateTopic.submitKey.ed25519 == ed25519_public.to_bytes_raw() |
575 | 576 | assert transaction_body.consensusCreateTopic.fee_schedule_key.HasField("ECDSA_secp256k1") |
576 | 577 | assert len(transaction_body.consensusCreateTopic.fee_exempt_key_list) == 2 |
| 578 | + |
| 579 | + |
| 580 | +def test_freeze_with_defaults_auto_renew_account_to_operator(mock_client): |
| 581 | + """Test that freeze_with sets auto_renew_account to operator when not explicitly set.""" |
| 582 | + tx = TopicCreateTransaction(memo="test topic") |
| 583 | + frozen_tx = tx.freeze_with(mock_client) |
| 584 | + body = frozen_tx.build_transaction_body() |
| 585 | + |
| 586 | + assert body.consensusCreateTopic.autoRenewAccount == mock_client.operator_account_id._to_proto() |
| 587 | + |
| 588 | + |
| 589 | +def test_freeze_with_preserves_explicit_auto_renew_account(mock_client): |
| 590 | + """Test that freeze_with does not override an explicitly set auto_renew_account.""" |
| 591 | + explicit_account = AccountId(0, 0, 9999) |
| 592 | + tx = TopicCreateTransaction(memo="test topic", auto_renew_account=explicit_account) |
| 593 | + frozen_tx = tx.freeze_with(mock_client) |
| 594 | + body = frozen_tx.build_transaction_body() |
| 595 | + |
| 596 | + assert body.consensusCreateTopic.autoRenewAccount == explicit_account._to_proto() |
| 597 | + |
| 598 | + |
| 599 | +def test_freeze_with_uses_transaction_id_account_when_set(mock_client): |
| 600 | + """Test that freeze_with uses transaction_id.account_id when transaction_id is set.""" |
| 601 | + tx_account = AccountId(0, 0, 5555) |
| 602 | + tx = TopicCreateTransaction(memo="test topic") |
| 603 | + tx.transaction_id = TransactionId.generate(tx_account) |
| 604 | + frozen_tx = tx.freeze_with(mock_client) |
| 605 | + body = frozen_tx.build_transaction_body() |
| 606 | + |
| 607 | + assert body.consensusCreateTopic.autoRenewAccount == tx_account._to_proto() |
| 608 | + |
| 609 | + |
| 610 | +def test_freeze_with_auto_renew_account_set_via_setter(mock_client): |
| 611 | + """Test that freeze_with preserves auto_renew_account set via set_auto_renew_account.""" |
| 612 | + explicit_account = AccountId(0, 0, 7777) |
| 613 | + tx = TopicCreateTransaction(memo="test topic") |
| 614 | + tx.set_auto_renew_account(explicit_account) |
| 615 | + frozen_tx = tx.freeze_with(mock_client) |
| 616 | + body = frozen_tx.build_transaction_body() |
| 617 | + |
| 618 | + assert body.consensusCreateTopic.autoRenewAccount == explicit_account._to_proto() |
| 619 | + |
| 620 | + |
| 621 | +def test_freeze_with_leaves_auto_renew_account_unset_without_operator(mock_client): |
| 622 | + """Test that freeze_with leaves auto_renew_account unset when operator_account_id is None.""" |
| 623 | + mock_client.operator_account_id = None |
| 624 | + tx = TopicCreateTransaction(memo="test topic") |
| 625 | + tx.transaction_id = TransactionId.generate(AccountId(0, 0, 1234)) |
| 626 | + frozen_tx = tx.freeze_with(mock_client) |
| 627 | + body = frozen_tx.build_transaction_body() |
| 628 | + |
| 629 | + assert not body.consensusCreateTopic.HasField("autoRenewAccount") |
0 commit comments