@@ -61,19 +61,15 @@ def unpausable_token(env):
6161@mark .parametrize (
6262 "token_id, exception, msg" ,
6363 [
64- (None , ValueError , "token_id must be set" ),
65- (TokenId (0 , 0 , 99999999 ), PrecheckError , ResponseCode .get_name (ResponseCode .INVALID_TOKEN_ID )),
66- # (lazy_fixture("unpausable_token"), PrecheckError, ResponseCode.get_name(ResponseCode.TOKEN_HAS_NO_PAUSE_KEY)),
64+ (None , ValueError , "token_id must be set" ),
65+ (TokenId (0 , 0 , 99999999 ), PrecheckError , ResponseCode .get_name (ResponseCode .INVALID_TOKEN_ID )),
6766 ],
68-
6967)
70-
7168def test_pause_error_cases (env , token_id , exception , msg ):
7269 """
7370 Invalid-pause scenarios:
7471 1) missing token_id
7572 2) non-existent token_id
76- 3) token exists but has no pause key
7773 """
7874 tx = TokenPauseTransaction ()
7975 if token_id is not None :
@@ -83,9 +79,23 @@ def test_pause_error_cases(env, token_id, exception, msg):
8379 with pytest .raises (ValueError , match = msg ):
8480 tx .freeze_with (env .client )
8581 else :
86- with pytest .raises (exception , match = msg ):
82+ with pytest .raises (PrecheckError , match = msg ):
8783 tx .freeze_with (env .client )
8884
85+ @mark .integration
86+ def test_pause_error_without_pause_key (env , unpausable_token ):
87+ """
88+ If a token exists but was created with no pause key,
89+ attempting to freeze it should fail with TOKEN_HAS_NO_PAUSE_KEY.
90+ """
91+ tx = TokenPauseTransaction ().set_token_id (unpausable_token )
92+
93+ with pytest .raises (
94+ PrecheckError ,
95+ match = ResponseCode .get_name (ResponseCode .TOKEN_HAS_NO_PAUSE_KEY ),
96+ ):
97+ tx .freeze_with (env .client )
98+
8999@mark .integration
90100class TestTokenPause :
91101 """Integration tests for pausing tokens."""
@@ -126,11 +136,12 @@ def test_transfers_blocked_when_paused(self, env, account: Account, pausable_tok
126136 with pytest .raises (ReceiptStatusError , match = ResponseCode .TOKEN_IS_PAUSED .name ):
127137 env .associate_and_transfer (account .id , account .key , pausable_token , 1 )
128138
139+ @mark .integration
129140@mark .parametrize ("bad_key, code" , [
130141 (None , ResponseCode .TOKEN_HAS_NO_PAUSE_KEY ),
131142 (PrivateKey .generate (), ResponseCode .INVALID_PAUSE_KEY ),
132143])
133- def test_double_pause_errors (self , env , pausable_token , bad_key , code ):
144+ def test_double_pause_errors (env , pausable_token , bad_key , code ):
134145 env .pause_token (pausable_token )
135146 with pytest .raises (ReceiptStatusError , match = ResponseCode .get_name (code )):
136147 env .pause_token (pausable_token , key = bad_key )
0 commit comments