Skip to content

Commit 7572375

Browse files
committed
feat: from proto get method tests
Signed-off-by: exploreriii <[email protected]>
1 parent ec94f0b commit 7572375

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

tests/unit/test_token_pause_transaction.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def _make(pause_key):
3838

3939
return _make
4040

41-
4241
def test_builds_token_pause_body_with_correct_ids(mock_account_ids, generate_transaction_id):
4342
"""
4443
build_transaction_body() should embed:
@@ -58,7 +57,6 @@ def test_builds_token_pause_body_with_correct_ids(mock_account_ids, generate_tra
5857
assert body.transactionID == pause_tx.transaction_id.to_proto()
5958
assert body.nodeAccountID == pause_tx.node_account_id.to_proto()
6059

61-
6260
@pytest.mark.parametrize("bad_token", [None, TokenId(0, 0, 0)])
6361
def test_build_transaction_body_without_valid_token_id_raises(bad_token):
6462
"""
@@ -71,6 +69,27 @@ def test_build_transaction_body_without_valid_token_id_raises(bad_token):
7169
with pytest.raises(ValueError, match="token_id must be set"):
7270
pause_tx.build_transaction_body()
7371

72+
def test__get_method_points_to_pauseToken(mock_channel):
73+
"""
74+
_get_method() should route to the gRPC stub method for pausing tokens.
75+
"""
76+
tx = TokenPauseTransaction().set_token_id(TokenId(1, 2, 3))
77+
method = tx._get_method(mock_channel)
78+
79+
assert method.transaction_func is mock_channel.token.pauseToken
80+
assert method.query_func is None
81+
82+
def test__from_proto_restores_token_id():
83+
"""
84+
_from_proto() should deserialize a TokenPauseTransactionBody back into .token_id.
85+
"""
86+
proto_body = TokenPauseTransaction._get_transaction_body_class()(
87+
token=TokenId(7, 8, 9).to_proto()
88+
)
89+
pause_tx = TokenPauseTransaction()._from_proto(proto_body)
90+
91+
assert pause_tx.token_id == TokenId(7, 8, 9)
92+
7493
def test_signed_bytes_include_token_pause_transaction(built_pause_tx):
7594
"""
7695
After freeze() and sign(pause_key), to_proto() must embed a non-empty
@@ -131,5 +150,3 @@ def test_pause_transaction_can_execute(mock_account_ids):
131150

132151
receipt = pause_tx.execute(client)
133152
assert receipt.status == ResponseCode.SUCCESS
134-
135-

0 commit comments

Comments
 (0)