1616from hiero_sdk_python .query .account_balance_query import CryptoGetAccountBalanceQuery
1717# from hiero_sdk_python.query.token_info_query import TokenInfoQuery
1818
19+ pause_key = PrivateKey .generate ()
20+
1921@fixture
2022def env ():
2123 """Integration test environment with client/operator set up."""
@@ -29,10 +31,11 @@ def account(env):
2931 return env .create_account ()
3032
3133# Uses lambda opts to add a pause key → pausable
34+ # Create a unique pause key to enable varied tests
3235# Signing by the treasury account handled by the executable method in env
3336@fixture
3437def pausable_token (env ):
35- return create_fungible_token (env , opts = [lambda tx : tx .set_pause_key (env . operator_key )])
38+ return create_fungible_token (env , opts = [lambda tx : tx .set_pause_key (pause_key )])
3639
3740# Fungible token in env has no pause key
3841@fixture
@@ -84,23 +87,23 @@ def test_pause_fails_for_unpausable_token(env, unpausable_token):
8487def test_pause_requires_pause_key_signature (env , pausable_token ):
8588 """
8689 A pausable token has a pause key. If you submit a pause tx without
87- that pause-key signature, you get TOKEN_HAS_NO_PAUSE_KEY .
90+ that pause-key signature, the service rejects it with INVALID_SIGNATURE .
8891 """
8992 # Build & freeze, but never sign with the pause key:
9093 tx = TokenPauseTransaction ().set_token_id (pausable_token )
9194 tx = tx .freeze_with (env .client )
92- receipt = tx .execute (env .client )
95+ receipt = tx .execute (env .client ) # This autosigns with operator key, which is different to the pause key
9396
94- assert receipt .status == ResponseCode .TOKEN_HAS_NO_PAUSE_KEY , (
95- f"Expected TOKEN_HAS_NO_PAUSE_KEY but got "
97+ assert receipt .status == ResponseCode .INVALID_SIGNATURE , (
98+ f"Expected INVALID_SIGNATURE but got "
9699 f"{ ResponseCode .get_name (receipt .status )} "
97100 )
98101
99102@mark .integration
100103def test_pause_with_invalid_key (env , pausable_token ):
101104 """
102105 A pausable token created with a pause key must be signed with it—
103- signing with some other key causes an INVALID_PAUSE_KEY .
106+ signing with some other key causes an INVALID_SIGNATURE .
104107 """
105108 bad_key = PrivateKey .generate ()
106109
@@ -109,42 +112,11 @@ def test_pause_with_invalid_key(env, pausable_token):
109112 tx = tx .sign (bad_key ) # ← signed with wrong key
110113 receipt = tx .execute (env .client )
111114
112- assert receipt .status == ResponseCode .INVALID_PAUSE_KEY , (
113- f"Expected INVALID_PAUSE_KEY but got "
115+ assert receipt .status == ResponseCode .INVALID_SIGNATURE , (
116+ f"Expected INVALID_SIGNATURE but got "
114117 f"{ ResponseCode .get_name (receipt .status )} "
115118 )
116119
117-
118- @mark .integration
119- def test_pause_already_paused_token_fails (env , pausable_token ):
120- """
121- Attempting to pause a token that is already paused should fail
122- with TOKEN_IS_PAUSED.
123- """
124- # 1) First pause: build, freeze, sign with the real pause key, execute
125- tx1 = (
126- TokenPauseTransaction ()
127- .set_token_id (pausable_token )
128- .freeze_with (env .client )
129- .sign (env .operator_key )
130- )
131- receipt1 = tx1 .execute (env .client )
132- assert receipt1 .status == ResponseCode .SUCCESS
133-
134- # 2) Second pause: do the exact same, but now expect TOKEN_IS_PAUSED
135- tx2 = (
136- TokenPauseTransaction ()
137- .set_token_id (pausable_token )
138- .freeze_with (env .client )
139- .sign (env .operator_key )
140- )
141- receipt2 = tx2 .execute (env .client )
142-
143- assert receipt2 .status == ResponseCode .TOKEN_IS_PAUSED , (
144- f"Expected TOKEN_IS_PAUSED but got "
145- f"{ ResponseCode .get_name (receipt2 .status )} "
146- )
147-
148120@mark .integration
149121def test_transfer_before_pause (env , account : Account , pausable_token ):
150122 """
@@ -168,7 +140,6 @@ def test_pause_sets_token_status_to_paused(env, pausable_token):
168140 assert info .token_status .name == "UNPAUSED"
169141
170142 # 2) build, freeze, sign & execute the pause tx
171- pause_key = env .operator_key
172143 tx = (
173144 TokenPauseTransaction ()
174145 .set_token_id (pausable_token )
@@ -205,7 +176,7 @@ def test_transfers_blocked_when_paused(env, account: Account, pausable_token):
205176 TokenPauseTransaction ()
206177 .set_token_id (pausable_token )
207178 .freeze_with (env .client )
208- .sign (env . operator_key )
179+ .sign (pause_key )
209180 )
210181 pause_receipt = pause_tx .execute (env .client )
211182 assert pause_receipt .status == ResponseCode .SUCCESS
0 commit comments