@@ -2,6 +2,7 @@ import type { EpochCache } from '@aztec/epoch-cache';
2
2
import { EthAddress } from '@aztec/foundation/eth-address' ;
3
3
import { sleep } from '@aztec/foundation/sleep' ;
4
4
import { L2Block , type L2BlockSourceEventEmitter , L2BlockSourceEvents } from '@aztec/stdlib/block' ;
5
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers' ;
5
6
import type {
6
7
BuildBlockResult ,
7
8
IFullNodeBlockBuilder ,
@@ -28,6 +29,10 @@ describe('EpochPruneWatcher', () => {
28
29
let txProvider : MockProxy < Pick < ITxProvider , 'getAvailableTxs' > > ;
29
30
let blockBuilder : MockProxy < IFullNodeBlockBuilder > ;
30
31
let fork : MockProxy < MerkleTreeWriteOperations > ;
32
+
33
+ let ts : bigint ;
34
+ let l1Constants : L1RollupConstants ;
35
+
31
36
const validEpochPrunedPenalty = BigInt ( 1000000000000000000n ) ;
32
37
const dataWithholdingPenalty = BigInt ( 2000000000000000000n ) ;
33
38
@@ -41,6 +46,18 @@ describe('EpochPruneWatcher', () => {
41
46
fork = mock < MerkleTreeWriteOperations > ( ) ;
42
47
blockBuilder . getFork . mockResolvedValue ( fork ) ;
43
48
49
+ ts = BigInt ( Math . ceil ( Date . now ( ) / 1000 ) ) ;
50
+ l1Constants = {
51
+ l1StartBlock : 1n ,
52
+ l1GenesisTime : ts ,
53
+ slotDuration : 24 ,
54
+ epochDuration : 8 ,
55
+ ethereumSlotDuration : 12 ,
56
+ proofSubmissionEpochs : 1 ,
57
+ } ;
58
+
59
+ epochCache . getL1Constants . mockReturnValue ( l1Constants ) ;
60
+
44
61
watcher = new EpochPruneWatcher ( l2BlockSource , l1ToL2MessageSource , epochCache , txProvider , blockBuilder , {
45
62
slashPrunePenalty : validEpochPrunedPenalty ,
46
63
slashDataWithholdingPenalty : dataWithholdingPenalty ,
@@ -54,9 +71,10 @@ describe('EpochPruneWatcher', () => {
54
71
55
72
it ( 'should emit WANT_TO_SLASH_EVENT when a validator is in a pruned epoch when data is unavailable' , async ( ) => {
56
73
const emitSpy = jest . spyOn ( watcher , 'emit' ) ;
74
+ const epochNumber = 1n ;
57
75
58
76
const block = await L2Block . random (
59
- 1 , // block number
77
+ 12 , // block number
60
78
4 , // txs per block
61
79
) ;
62
80
txProvider . getAvailableTxs . mockResolvedValue ( { txs : [ ] , missingTxs : [ block . body . txEffects [ 0 ] . txHash ] } ) ;
@@ -68,11 +86,11 @@ describe('EpochPruneWatcher', () => {
68
86
epochCache . getCommitteeForEpoch . mockResolvedValue ( {
69
87
committee : committee . map ( EthAddress . fromString ) ,
70
88
seed : 0n ,
71
- epoch : 1n ,
89
+ epoch : epochNumber ,
72
90
} ) ;
73
91
74
92
l2BlockSource . emit ( L2BlockSourceEvents . L2PruneDetected , {
75
- epochNumber : 1n ,
93
+ epochNumber,
76
94
blocks : [ block ] ,
77
95
type : L2BlockSourceEvents . L2PruneDetected ,
78
96
} ) ;
@@ -85,13 +103,13 @@ describe('EpochPruneWatcher', () => {
85
103
validator : EthAddress . fromString ( committee [ 0 ] ) ,
86
104
amount : dataWithholdingPenalty ,
87
105
offenseType : OffenseType . DATA_WITHHOLDING ,
88
- epochOrSlot : 1n ,
106
+ epochOrSlot : epochNumber ,
89
107
} ,
90
108
{
91
109
validator : EthAddress . fromString ( committee [ 1 ] ) ,
92
110
amount : dataWithholdingPenalty ,
93
111
offenseType : OffenseType . DATA_WITHHOLDING ,
94
- epochOrSlot : 1n ,
112
+ epochOrSlot : epochNumber ,
95
113
} ,
96
114
] satisfies WantToSlashArgs [ ] ) ;
97
115
} ) ;
@@ -100,7 +118,7 @@ describe('EpochPruneWatcher', () => {
100
118
const emitSpy = jest . spyOn ( watcher , 'emit' ) ;
101
119
102
120
const block = await L2Block . random (
103
- 1 , // block number
121
+ 12 , // block number
104
122
4 , // txs per block
105
123
) ;
106
124
const tx = Tx . random ( ) ;
@@ -152,11 +170,11 @@ describe('EpochPruneWatcher', () => {
152
170
const emitSpy = jest . spyOn ( watcher , 'emit' ) ;
153
171
154
172
const blockFromL1 = await L2Block . random (
155
- 1 , // block number
173
+ 12 , // block number
156
174
1 , // txs per block
157
175
) ;
158
176
const blockFromBuilder = await L2Block . random (
159
- 2 , // block number
177
+ 13 , // block number
160
178
1 , // txs per block
161
179
) ;
162
180
const tx = Tx . random ( ) ;
0 commit comments