1
+ """
2
+ Tests for voting 03/04/2025 [HOLESKY].
3
+ """
4
+
5
+ from scripts .vote_2024_12_17_holesky import start_vote
6
+ from brownie import interface , reverts , chain
7
+ from utils .test .tx_tracing_helpers import *
8
+ from utils .config import contracts , LDO_HOLDER_ADDRESS_FOR_TESTS
9
+ from utils .config import contracts
10
+ from utils .test .easy_track_helpers import create_and_enact_payment_motion
11
+ from utils .test .event_validators .allowed_recipients_registry import (
12
+ validate_set_limit_parameter_event ,
13
+ )
14
+
15
+ def test_vote (helpers , accounts , vote_ids_from_env , stranger ):
16
+
17
+ # common values
18
+ STETH = interface .StETH ("0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034" )
19
+ easy_track = interface .EasyTrack ("0x1763b9ED3586B08AE796c7787811a2E1bc16163a" )
20
+ lol_allowed_recipients_registry = interface .AllowedRecipientRegistry ("0x55B304a585D540421F1fD3579Ef12Abab7304492" )
21
+ lol_allowed_recipient = accounts .at ("0x1580881349e214Bab9f1E533bF97351271DB95a9" , force = True )
22
+ lol_trusted_caller_acc = accounts .at ("0x96d2Ff1C4D30f592B91fd731E218247689a76915" , force = True )
23
+ lol_top_up_evm_script_factory = interface .TopUpAllowedRecipients ("0xBB06DD9a3C7eE8cE093860094e769a1E3D6F97F6" )
24
+
25
+ # before values
26
+ lol_budget_limit_before_exptected = 210 * 10 ** 18
27
+ lol_period_duration_months_before_expected = 3
28
+ lol_period_start_before_exptected = 1704067200 # Mon Jan 01 2024 00:00:00 GMT+0000
29
+ lol_period_end_before_exptected = 1711929600 # Mon Apr 01 2024 00:00:00 GMT+0000
30
+
31
+ # after values
32
+ lol_budget_limit_after_expected = 500 * 10 ** 18
33
+ lol_period_duration_months_after_expected = 6
34
+ lol_period_start_after_exptected = 1735689600 # Wed Jan 01 2025 00:00:00 GMT+0000
35
+ lol_period_end_after_exptected = 1751328000 # Tue Jul 01 2025 00:00:00 GMT+0000
36
+
37
+ #scenario test values
38
+ h2_motion_time = 1751328001 # Tue Jul 01 2025 00:00:01 GMT+0000
39
+ h2_period_start = 1751328000 # Tue Jul 01 2025 00:00:00 GMT+0000
40
+ h2_period_end = 1767225600 # Thu Jan 01 2026 00:00:00 GMT+0000
41
+
42
+
43
+ # checks before
44
+ lol_budget_limit_before , lol_period_duration_months_before = interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).getLimitParameters ()
45
+ _ , _ , lol_period_start_before , lol_period_end_before = lol_allowed_recipients_registry .getPeriodState ()
46
+ lol_spendable_balance_before = interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).spendableBalance ()
47
+ assert lol_budget_limit_before == lol_budget_limit_before_exptected
48
+ assert lol_period_duration_months_before == lol_period_duration_months_before_expected
49
+ assert lol_period_start_before == lol_period_start_before_exptected
50
+ assert lol_period_end_before == lol_period_end_before_exptected
51
+
52
+
53
+ # START VOTE
54
+ if len (vote_ids_from_env ) > 0 :
55
+ (vote_id ,) = vote_ids_from_env
56
+ else :
57
+ tx_params = {"from" : LDO_HOLDER_ADDRESS_FOR_TESTS }
58
+ vote_id , _ = start_vote (tx_params , silent = True )
59
+ vote_tx = helpers .execute_vote (accounts , vote_id , contracts .voting )
60
+ print (f"voteId = { vote_id } , gasUsed = { vote_tx .gas_used } " )
61
+
62
+
63
+ # checks after
64
+ lol_budget_limit_after , lol_period_duration_months_after = interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).getLimitParameters ()
65
+ _ , _ , lol_period_start_after , lol_period_end_after = interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).getPeriodState ()
66
+ lol_spendable_balance_after = interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).spendableBalance ()
67
+ assert lol_period_start_after == lol_period_start_after_exptected
68
+ assert lol_period_end_after == lol_period_end_after_exptected
69
+ assert lol_budget_limit_after == lol_budget_limit_after_expected
70
+ assert lol_period_duration_months_after == lol_period_duration_months_after_expected
71
+ assert lol_spendable_balance_before + (lol_budget_limit_after_expected - lol_budget_limit_before_exptected ) == lol_spendable_balance_after
72
+
73
+
74
+ # check events
75
+ display_voting_events (vote_tx )
76
+ evs = group_voting_events (vote_tx )
77
+
78
+ assert count_vote_items_by_events (vote_tx , contracts .voting ) == 1 , "Incorrect voting items count"
79
+
80
+ validate_set_limit_parameter_event (
81
+ evs [0 ],
82
+ limit = lol_budget_limit_after_expected ,
83
+ period_duration_month = lol_period_duration_months_after_expected ,
84
+ period_start_timestamp = lol_period_start_after_exptected ,
85
+ )
86
+
87
+ # scenario tests
88
+
89
+ # full withdrawal in H1'2025
90
+ limit_test (easy_track ,
91
+ interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).spendableBalance (),
92
+ lol_trusted_caller_acc ,
93
+ lol_top_up_evm_script_factory ,
94
+ lol_allowed_recipient ,
95
+ stranger ,
96
+ STETH ,
97
+ 100 * 10 ** 18
98
+ )
99
+
100
+ # partial withdrawal of 300 steth in H2'2025
101
+
102
+ # wait until H2'2025
103
+ chain .sleep (h2_motion_time - chain .time ())
104
+ chain .mine ()
105
+ assert chain .time () == h2_motion_time
106
+
107
+ # pay 100 steth
108
+ create_and_enact_payment_motion (
109
+ easy_track ,
110
+ lol_trusted_caller_acc ,
111
+ lol_top_up_evm_script_factory ,
112
+ STETH ,
113
+ [lol_allowed_recipient ],
114
+ [100 * 10 ** 18 ],
115
+ stranger ,
116
+ )
117
+
118
+ # pay 100 steth
119
+ create_and_enact_payment_motion (
120
+ easy_track ,
121
+ lol_trusted_caller_acc ,
122
+ lol_top_up_evm_script_factory ,
123
+ STETH ,
124
+ [lol_allowed_recipient ],
125
+ [100 * 10 ** 18 ],
126
+ stranger ,
127
+ )
128
+
129
+ # pay 100 steth
130
+ create_and_enact_payment_motion (
131
+ easy_track ,
132
+ lol_trusted_caller_acc ,
133
+ lol_top_up_evm_script_factory ,
134
+ STETH ,
135
+ [lol_allowed_recipient ],
136
+ [100 * 10 ** 18 ],
137
+ stranger ,
138
+ )
139
+
140
+ lol_already_spent_h2 , _ , lol_period_start_h2 , lol_period_end_h2 = lol_allowed_recipients_registry .getPeriodState ()
141
+ assert lol_already_spent_h2 == 300 * 10 ** 18
142
+ assert lol_period_start_h2 == h2_period_start
143
+ assert lol_period_end_h2 == h2_period_end
144
+ assert interface .AllowedRecipientRegistry (lol_allowed_recipients_registry ).spendableBalance () == 200 * 10 ** 18
145
+
146
+ def limit_test (easy_track , to_spend , trusted_caller_acc , top_up_evm_script_factory , send_to , stranger , token , max_spend_at_once ):
147
+
148
+ # check that there is no way to spend more then expected
149
+ with reverts ("SUM_EXCEEDS_SPENDABLE_BALANCE" ):
150
+ create_and_enact_payment_motion (
151
+ easy_track ,
152
+ trusted_caller_acc ,
153
+ top_up_evm_script_factory ,
154
+ token ,
155
+ [send_to ],
156
+ [to_spend + 1 ],
157
+ stranger ,
158
+ )
159
+
160
+ # spend all step by step
161
+ while to_spend > 0 :
162
+ create_and_enact_payment_motion (
163
+ easy_track ,
164
+ trusted_caller_acc ,
165
+ top_up_evm_script_factory ,
166
+ token ,
167
+ [send_to ],
168
+ [min (max_spend_at_once , to_spend )],
169
+ stranger ,
170
+ )
171
+ to_spend -= min (max_spend_at_once , to_spend )
172
+
173
+ # make sure there is nothing left so that you can't spend anymore
174
+ with reverts ("SUM_EXCEEDS_SPENDABLE_BALANCE" ):
175
+ create_and_enact_payment_motion (
176
+ easy_track ,
177
+ trusted_caller_acc ,
178
+ top_up_evm_script_factory ,
179
+ token ,
180
+ [send_to ],
181
+ [1 ],
182
+ stranger ,
183
+ )
0 commit comments