@@ -87,7 +87,7 @@ contract BaseHookTest is Test, Deployers {
87
87
function test_vote_succeeds (address _actor ) public {
88
88
deployGovernor (address (hook));
89
89
90
- vm. assume ( _actor != proxyAdmin && _actor != address (hook) );
90
+ _actor = makeAddr ( " actor " );
91
91
92
92
vm.prank (minter);
93
93
token.mint (_actor, 100 );
@@ -115,4 +115,103 @@ contract BaseHookTest is Test, Deployers {
115
115
vm.roll (block .number + 14 );
116
116
vm.stopPrank ();
117
117
}
118
+
119
+ function test_cancel_succeeds () public {
120
+ deployGovernor (address (hook));
121
+
122
+ address [] memory targets = new address [](1 );
123
+ targets[0 ] = address (this );
124
+ uint256 [] memory values = new uint256 [](1 );
125
+ bytes [] memory calldatas = new bytes [](1 );
126
+ calldatas[0 ] = abi.encodeWithSelector (this .test_initialize_succeeds.selector );
127
+
128
+ vm.startPrank (manager);
129
+ uint256 proposalId = governor.propose (targets, values, calldatas, "Test " );
130
+
131
+ vm.roll (block .number + 2 );
132
+
133
+ vm.expectEmit (address (hook));
134
+ emit BaseHookMock.BeforeCancel ();
135
+ vm.expectEmit (address (hook));
136
+ emit BaseHookMock.AfterCancel ();
137
+ governor.cancel (targets, values, calldatas, keccak256 ("Test " ));
138
+
139
+ vm.stopPrank ();
140
+ }
141
+
142
+ function test_queue_succeeds (address _actor ) public {
143
+ deployGovernor (address (hook));
144
+
145
+ _actor = makeAddr ("actor " );
146
+
147
+ vm.prank (minter);
148
+ token.mint (_actor, 100 );
149
+ vm.startPrank (_actor);
150
+ token.delegate (_actor);
151
+ vm.roll (block .number + 1 );
152
+
153
+ address [] memory targets = new address [](1 );
154
+ targets[0 ] = address (this );
155
+ uint256 [] memory values = new uint256 [](1 );
156
+ bytes [] memory calldatas = new bytes [](1 );
157
+ calldatas[0 ] = abi.encodeWithSelector (this .test_initialize_succeeds.selector );
158
+
159
+ vm.startPrank (_actor);
160
+ uint256 proposalId = governor.propose (targets, values, calldatas, "Test " );
161
+
162
+ vm.roll (block .number + 2 );
163
+
164
+ governor.castVote (proposalId, uint8 (GovernorCountingSimple.VoteType.For));
165
+
166
+ vm.roll (block .number + 14 );
167
+
168
+ vm.expectEmit (address (hook));
169
+ emit BaseHookMock.BeforeQueue ();
170
+ vm.expectEmit (address (hook));
171
+ emit BaseHookMock.AfterQueue ();
172
+ governor.queue (targets, values, calldatas, keccak256 ("Test " ));
173
+ }
174
+
175
+ function test_execute_succeeds (
176
+ address _actor ,
177
+ uint256 _proposalTargetCalldata ,
178
+ uint256 _elapsedAfterQueuing
179
+ ) public {
180
+ deployGovernor (address (hook));
181
+
182
+ _actor = makeAddr ("actor " );
183
+
184
+ _elapsedAfterQueuing = bound (_elapsedAfterQueuing, timelockDelay, type (uint208 ).max);
185
+
186
+ vm.prank (minter);
187
+ token.mint (_actor, 100 );
188
+ vm.startPrank (_actor);
189
+ token.delegate (_actor);
190
+ vm.roll (block .number + 1 );
191
+
192
+ address [] memory targets = new address [](1 );
193
+ targets[0 ] = address (this );
194
+ uint256 [] memory values = new uint256 [](1 );
195
+ bytes [] memory calldatas = new bytes [](1 );
196
+ calldatas[0 ] = abi.encodeWithSelector (this .test_initialize_succeeds.selector );
197
+
198
+ vm.startPrank (_actor);
199
+ uint256 proposalId = governor.propose (targets, values, calldatas, "Test " );
200
+
201
+ vm.roll (block .number + 2 );
202
+
203
+ governor.castVote (proposalId, uint8 (GovernorCountingSimple.VoteType.For));
204
+
205
+ vm.roll (block .number + 14 );
206
+
207
+ governor.queue (targets, values, calldatas, keccak256 ("Test " ));
208
+ vm.warp (block .timestamp + _elapsedAfterQueuing);
209
+
210
+ vm.expectEmit (address (hook));
211
+ emit BaseHookMock.BeforeExecute ();
212
+ vm.expectCall (
213
+ address (hook), abi.encodeCall (hook.afterExecute, (_actor, proposalId, targets, values, calldatas, keccak256 ("Test " )))
214
+ );
215
+ governor.execute (targets, values, calldatas, keccak256 ("Test " ));
216
+ }
118
217
}
0 commit comments