Skip to content

Commit 97edaea

Browse files
committed
refactor: add with reverts()
1 parent e26908c commit 97edaea

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/test_vote_tw_csm2.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Dict, Tuple, List, NamedTuple, Optional, Any, Sequence
66
from scripts.vote_tw_csm2 import create_tw_vote
7-
from brownie import interface, chain, convert, web3, ZERO_ADDRESS
7+
from brownie import interface, reverts, chain, convert, web3, ZERO_ADDRESS
88
from brownie.network.event import EventDict
99
from utils.easy_track import create_permissions
1010
from utils.test.tx_tracing_helpers import count_vote_items_by_events, group_voting_events_from_receipt, group_dg_events_from_receipt
@@ -288,17 +288,17 @@ def test_tw_vote(helpers, accounts, vote_ids_from_env, stranger):
288288
assert csm_impl_before != CSM_IMPL_V2_ADDRESS, "CSM implementation should be different before vote"
289289

290290
# Step 30: Check CSM finalizeUpgradeV2 initial state
291-
try:
292-
version = contracts.csm.getInitializedVersion()
293-
assert version < CSM_V2_VERSION, f"CSM version should be less than {CSM_V2_VERSION} before vote"
294-
except Exception:
295-
pass # Function might not exist yet
291+
with reverts():
292+
# The function should not exist yet
293+
contracts.csm.getInitializedVersion()
296294

297295
# CSM Step 32: Check CSAccounting implementation (pre-vote state)
298296
assert cs_accounting_impl_before != CS_ACCOUNTING_IMPL_V2_ADDRESS, "CSAccounting implementation should be different before vote"
299297

300298
# CSM Step 33: Check CSAccounting finalizeUpgradeV2 was not called (pre-vote state)
301-
# assert contracts.cs_accounting.getInitializedVersion() < CS_ACCOUNTING_V2_VERSION, f"CSAccounting version should be less than {CS_ACCOUNTING_V2_VERSION} before vote"
299+
with reverts():
300+
# The function should not exist yet
301+
contracts.cs_accounting.getInitializedVersion()
302302

303303
# CSM Step 34: Check CSFeeOracle implementation (pre-vote state)
304304
assert cs_fee_oracle_impl_before != CS_FEE_ORACLE_IMPL_V2_ADDRESS, "CSFeeOracle implementation should be different before vote"
@@ -311,7 +311,9 @@ def test_tw_vote(helpers, accounts, vote_ids_from_env, stranger):
311311
assert cs_fee_distributor_impl_before != CS_FEE_DISTRIBUTOR_IMPL_V2_ADDRESS, "CSFeeDistributor implementation should be different before vote"
312312

313313
# CSM Step 37: Check CSFeeDistributor finalizeUpgradeV2 was not called (pre-vote state)
314-
# assert contracts.cs_fee_distributor.getInitializedVersion() < CS_FEE_DISTRIBUTOR_V2_VERSION, f"CSFeeDistributor version should be less than {CS_FEE_DISTRIBUTOR_V2_VERSION} before vote"
314+
with reverts():
315+
# The function should not exist yet
316+
contracts.cs_fee_distributor.getInitializedVersion()
315317

316318
# CSM Steps 38-40: CSAccounting roles (pre-vote state)
317319
assert contracts.cs_accounting.hasRole(contracts.cs_accounting.SET_BOND_CURVE_ROLE(), contracts.csm.address), "CSM should have SET_BOND_CURVE_ROLE on CSAccounting before vote"

0 commit comments

Comments
 (0)