@@ -159,9 +159,12 @@ contract BribeInitiativeAllocateTest is Test {
159
159
160
160
function test_onAfterAllocateLQTY_newEpoch_NoVetoToVeto () public {
161
161
governance.setEpoch (1 );
162
+ vm.warp (governance.EPOCH_DURATION ()); // warp to end of first epoch
162
163
163
164
vm.startPrank (address (governance));
164
165
166
+ // set user2 allocations like governance would using onAfterAllocateLQTY at epoch 1
167
+ // sets avgTimestamp to current block.timestamp
165
168
{
166
169
IGovernance.UserState memory userState =
167
170
IGovernance.UserState ({allocatedLQTY: 1e18 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -184,6 +187,8 @@ contract BribeInitiativeAllocateTest is Test {
184
187
assertEq (userAverageTimestamp, uint32 (block .timestamp ));
185
188
}
186
189
190
+ // set user2 allocations like governance would using onAfterAllocateLQTY at epoch 1
191
+ // sets avgTimestamp to current block.timestamp
187
192
{
188
193
IGovernance.UserState memory userState =
189
194
IGovernance.UserState ({allocatedLQTY: 1e18 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -196,6 +201,7 @@ contract BribeInitiativeAllocateTest is Test {
196
201
lastEpochClaim: 0
197
202
});
198
203
bribeInitiative.onAfterAllocateLQTY (governance.epoch (), user2, userState, allocation, initiativeState);
204
+
199
205
(uint88 totalLQTYAllocated , uint32 totalAverageTimestamp ) =
200
206
bribeInitiative.totalLQTYAllocatedByEpoch (governance.epoch ());
201
207
assertEq (totalLQTYAllocated, 1001e18 );
@@ -206,16 +212,20 @@ contract BribeInitiativeAllocateTest is Test {
206
212
assertEq (userAverageTimestamp, uint32 (block .timestamp ));
207
213
}
208
214
215
+ // lusdHolder deposits bribes into the initiative
209
216
vm.startPrank (lusdHolder);
210
217
lqty.approve (address (bribeInitiative), 1000e18 );
211
218
lusd.approve (address (bribeInitiative), 1000e18 );
212
219
bribeInitiative.depositBribe (1000e18 , 1000e18 , governance.epoch () + 1 );
213
220
vm.stopPrank ();
214
221
215
222
governance.setEpoch (2 );
223
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to second epoch ts
216
224
217
225
vm.startPrank (address (governance));
218
226
227
+ // set allocation in initiative for user in epoch 1
228
+ // sets avgTimestamp to current block.timestamp
219
229
{
220
230
IGovernance.UserState memory userState =
221
231
IGovernance.UserState ({allocatedLQTY: 1e18 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -238,6 +248,8 @@ contract BribeInitiativeAllocateTest is Test {
238
248
assertEq (userAverageTimestamp, uint32 (block .timestamp ));
239
249
}
240
250
251
+ // set allocation in initiative for user2 in epoch 1
252
+ // sets avgTimestamp to current block.timestamp
241
253
{
242
254
IGovernance.UserState memory userState =
243
255
IGovernance.UserState ({allocatedLQTY: 1e18 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -260,7 +272,8 @@ contract BribeInitiativeAllocateTest is Test {
260
272
assertEq (userAverageTimestamp, uint32 (block .timestamp ));
261
273
}
262
274
263
- governance.setEpoch (3 );
275
+ governance.setEpoch (3 );
276
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to third epoch ts
264
277
265
278
vm.startPrank (address (user));
266
279
@@ -269,12 +282,13 @@ contract BribeInitiativeAllocateTest is Test {
269
282
claimData[0 ].prevLQTYAllocationEpoch = 2 ;
270
283
claimData[0 ].prevTotalLQTYAllocationEpoch = 2 ;
271
284
(uint256 boldAmount , uint256 bribeTokenAmount ) = bribeInitiative.claimBribes (claimData);
272
- assertEq (boldAmount, 0 );
273
- assertEq (bribeTokenAmount, 0 );
285
+ assertEq (boldAmount, 0 , " boldAmount nonzero " );
286
+ assertEq (bribeTokenAmount, 0 , " bribeTokenAmount nonzero " );
274
287
}
275
288
276
289
function test_onAfterAllocateLQTY_newEpoch_VetoToNoVeto () public {
277
290
governance.setEpoch (1 );
291
+ vm.warp (governance.EPOCH_DURATION ()); // warp to end of first epoch
278
292
279
293
vm.startPrank (address (governance));
280
294
@@ -325,6 +339,7 @@ contract BribeInitiativeAllocateTest is Test {
325
339
assertEq (userAverageTimestampAfterVeto, uint32 (block .timestamp ));
326
340
327
341
governance.setEpoch (2 );
342
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to second epoch ts
328
343
329
344
IGovernance.UserState memory userStateNewEpoch =
330
345
IGovernance.UserState ({allocatedLQTY: 1 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -359,6 +374,7 @@ contract BribeInitiativeAllocateTest is Test {
359
374
vm.startPrank (address (governance));
360
375
361
376
governance.setEpoch (3 );
377
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to third epoch ts
362
378
363
379
IGovernance.UserState memory userStateNewEpoch3 =
364
380
IGovernance.UserState ({allocatedLQTY: 2000e18 , averageStakingTimestamp: uint32 (block .timestamp )});
@@ -385,6 +401,7 @@ contract BribeInitiativeAllocateTest is Test {
385
401
assertEq (userAverageTimestampNewEpoch3, uint32 (block .timestamp ));
386
402
387
403
governance.setEpoch (4 );
404
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to fourth epoch ts
388
405
389
406
vm.startPrank (address (user));
390
407
@@ -509,6 +526,7 @@ contract BribeInitiativeAllocateTest is Test {
509
526
vm.stopPrank ();
510
527
511
528
governance.setEpoch (1 );
529
+ vm.warp (governance.EPOCH_DURATION ()); // warp to end of first epoch
512
530
513
531
vm.startPrank (address (governance));
514
532
@@ -585,6 +603,7 @@ contract BribeInitiativeAllocateTest is Test {
585
603
}
586
604
587
605
governance.setEpoch (2 );
606
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to second epoch ts
588
607
589
608
vm.startPrank (address (user));
590
609
@@ -603,6 +622,7 @@ contract BribeInitiativeAllocateTest is Test {
603
622
vm.stopPrank ();
604
623
605
624
governance.setEpoch (1 );
625
+ vm.warp (governance.EPOCH_DURATION ()); // warp to end of first epoch
606
626
607
627
vm.startPrank (address (governance));
608
628
@@ -679,6 +699,7 @@ contract BribeInitiativeAllocateTest is Test {
679
699
}
680
700
681
701
governance.setEpoch (2 );
702
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to second epoch ts
682
703
683
704
vm.startPrank (address (user));
684
705
@@ -699,6 +720,7 @@ contract BribeInitiativeAllocateTest is Test {
699
720
vm.stopPrank ();
700
721
701
722
governance.setEpoch (1 );
723
+ vm.warp (governance.EPOCH_DURATION ()); // warp to end of first epoch
702
724
703
725
vm.startPrank (address (governance));
704
726
@@ -799,6 +821,7 @@ contract BribeInitiativeAllocateTest is Test {
799
821
}
800
822
801
823
governance.setEpoch (2 );
824
+ vm.warp (block .timestamp + governance.EPOCH_DURATION ()); // warp to second epoch ts
802
825
803
826
vm.startPrank (address (user));
804
827
0 commit comments