Skip to content

Commit 3d9c5d5

Browse files
committed
chore: consistency with other tests
1 parent ad50637 commit 3d9c5d5

File tree

1 file changed

+69
-70
lines changed

1 file changed

+69
-70
lines changed

tests/integration/token_pause_transaction_e2e_test.py

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -131,76 +131,75 @@ def test_pause_already_paused_token_fails(env, pausable_token):
131131
tx2.execute(env.client)
132132

133133
@mark.integration
134-
class TestTokenPause:
135-
"""Integration tests for pausing tokens."""
136-
137-
def test_transfer_before_pause(self, env, account: Account, pausable_token):
138-
"""
139-
A pausable token is transferred in 10 units to a fresh account that has them associated.
140-
The receiver's balance increases by 10.
141-
"""
142-
env.associate_and_transfer(account.id, account.key, pausable_token, 10)
143-
144-
balance = CryptoGetAccountBalanceQuery(account.id).execute(env.client).token_balances[pausable_token]
145-
assert balance == 10
146-
147-
def test_pause_sets_token_status_to_paused(self, env, pausable_token):
148-
"""
149-
Take a pausable token (UNPAUSED), submit a pause transaction signed
150-
with its pause key, then verify it ends up PAUSED.
151-
"""
152-
# 1) pre-pause sanity check
153-
info = TokenInfoQuery().set_token_id(pausable_token).execute(env.client)
154-
155-
assert info.token_status.name == "UNPAUSED"
156-
157-
# 2) build, freeze, sign & execute the pause tx
158-
pause_key = env.operator_key
159-
tx = (
160-
TokenPauseTransaction()
161-
.set_token_id(pausable_token)
162-
.freeze_with(env.client)
163-
.sign(pause_key)
164-
)
165-
receipt = tx.execute(env.client)
166-
assert receipt.status == ResponseCode.SUCCESS
167-
168-
# 3) post-pause verify
169-
info2 = TokenInfoQuery().set_token_id(pausable_token).execute(env.client)
170-
171-
assert info2.token_status.name == "PAUSED"
172-
173-
def test_transfers_blocked_when_paused(self, env, account: Account, pausable_token):
174-
"""
175-
Pause a token.
176-
Now that the token is PAUSED, it cannot perform operations.
177-
For example, an attempt to transfer tokens fails with TOKEN_IS_PAUSED.
178-
"""
179-
# first associate (this must succeed)
180-
env.freeze_sign_execute(
181-
TokenAssociateTransaction()
182-
.set_account_id(account.id)
183-
.add_token_id(pausable_token),
184-
account.key,
185-
)
186-
187-
# pause the token
188-
pause_key = env.operator_key
189-
tx = (
190-
TokenPauseTransaction()
134+
def test_transfer_before_pause(env, account: Account, pausable_token):
135+
"""
136+
A pausable token is transferred in 10 units to a fresh account that has them associated.
137+
The receiver's balance increases by 10.
138+
"""
139+
env.associate_and_transfer(account.id, account.key, pausable_token, 10)
140+
141+
balance = CryptoGetAccountBalanceQuery(account.id).execute(env.client).token_balances[pausable_token]
142+
assert balance == 10
143+
144+
@mark.integration
145+
def test_pause_sets_token_status_to_paused(env, pausable_token):
146+
"""
147+
Take a pausable token (UNPAUSED), submit a pause transaction signed
148+
with its pause key, then verify it ends up PAUSED.
149+
"""
150+
# 1) pre-pause sanity check
151+
info = TokenInfoQuery().set_token_id(pausable_token).execute(env.client)
152+
153+
assert info.token_status.name == "UNPAUSED"
154+
155+
# 2) build, freeze, sign & execute the pause tx
156+
pause_key = env.operator_key
157+
tx = (
158+
TokenPauseTransaction()
159+
.set_token_id(pausable_token)
160+
.freeze_with(env.client)
161+
.sign(pause_key)
162+
)
163+
receipt = tx.execute(env.client)
164+
assert receipt.status == ResponseCode.SUCCESS
165+
166+
# 3) post-pause verify
167+
info2 = TokenInfoQuery().set_token_id(pausable_token).execute(env.client)
168+
169+
assert info2.token_status.name == "PAUSED"
170+
171+
@mark.integration
172+
def test_transfers_blocked_when_paused(env, account: Account, pausable_token):
173+
"""
174+
Pause a token.
175+
Now that the token is PAUSED, it cannot perform operations.
176+
For example, an attempt to transfer tokens fails with TOKEN_IS_PAUSED.
177+
"""
178+
# first associate (this must succeed)
179+
assoc_tx = (
180+
TokenAssociateTransaction()
181+
.set_account_id(account.id)
182+
.add_token_id(pausable_token)
183+
)
184+
assoc_tx = assoc_tx.freeze_with(env.client).sign(account.key)
185+
assoc_receipt = assoc_tx.execute(env.client)
186+
assert assoc_receipt.status == ResponseCode.SUCCESS
187+
188+
# pause the token
189+
pause_tx = (
190+
TokenPauseTransaction()
191191
.set_token_id(pausable_token)
192192
.freeze_with(env.client)
193-
.sign(pause_key)
194-
)
195-
receipt = tx.execute(env.client)
196-
assert receipt.status == ResponseCode.SUCCESS
197-
198-
# attempt to transfer 1 token
199-
tx = (
200-
TransferTransaction()
201-
.add_token_transfer(pausable_token, env.operator_id, -1)
202-
.add_token_transfer(pausable_token, account.id, 1)
203-
)
193+
.sign(env.operator_key)
194+
)
195+
pause_receipt = pause_tx.execute(env.client)
196+
assert pause_receipt.status == ResponseCode.SUCCESS
204197

205-
with pytest.raises(ReceiptStatusError, match=ResponseCode.get_name(ResponseCode.TOKEN_IS_PAUSED)):
206-
tx.execute(env.client)
198+
# attempt to transfer 1 token
199+
tx = (
200+
TransferTransaction()
201+
.add_token_transfer(pausable_token, env.operator_id, -1)
202+
.add_token_transfer(pausable_token, account.id, 1)
203+
)
204+
with pytest.raises(ReceiptStatusError, match=ResponseCode.get_name(ResponseCode.TOKEN_IS_PAUSED)):
205+
tx.execute(env.client)

0 commit comments

Comments
 (0)