@@ -138,145 +138,148 @@ func TestService_BeaconBlockSubscribe_UndefinedEeError(t *testing.T) {
138
138
}
139
139
140
140
func TestReconstructAndBroadcastBlobs (t * testing.T ) {
141
- rob , err := blocks .NewROBlob (
142
- & ethpb.BlobSidecar {
143
- SignedBlockHeader : & ethpb.SignedBeaconBlockHeader {
144
- Header : & ethpb.BeaconBlockHeader {
145
- ParentRoot : make ([]byte , 32 ),
146
- BodyRoot : make ([]byte , 32 ),
147
- StateRoot : make ([]byte , 32 ),
141
+ t .Run ("blobs" , func (t * testing.T ) {
142
+ rob , err := blocks .NewROBlob (
143
+ & ethpb.BlobSidecar {
144
+ SignedBlockHeader : & ethpb.SignedBeaconBlockHeader {
145
+ Header : & ethpb.BeaconBlockHeader {
146
+ ParentRoot : make ([]byte , 32 ),
147
+ BodyRoot : make ([]byte , 32 ),
148
+ StateRoot : make ([]byte , 32 ),
149
+ },
150
+ Signature : []byte ("signature" ),
148
151
},
149
- Signature : []byte ("signature" ),
150
- },
151
- })
152
- require .NoError (t , err )
152
+ })
153
+ require .NoError (t , err )
153
154
154
- chainService := & chainMock.ChainService {
155
- Genesis : time .Now (),
156
- }
155
+ chainService := & chainMock.ChainService {
156
+ Genesis : time .Now (),
157
+ }
157
158
158
- b := util .NewBeaconBlockDeneb ()
159
- sb , err := blocks .NewSignedBeaconBlock (b )
160
- require .NoError (t , err )
159
+ b := util .NewBeaconBlockDeneb ()
160
+ sb , err := blocks .NewSignedBeaconBlock (b )
161
+ require .NoError (t , err )
161
162
162
- tests := []struct {
163
- name string
164
- blobSidecars []blocks.VerifiedROBlob
165
- expectedBlobCount int
166
- }{
167
- {
168
- name : "Constructed 0 blobs" ,
169
- blobSidecars : nil ,
170
- expectedBlobCount : 0 ,
171
- },
172
- {
173
- name : "Constructed 6 blobs" ,
174
- blobSidecars : []blocks.VerifiedROBlob {
175
- {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob },
163
+ tests := []struct {
164
+ name string
165
+ blobSidecars []blocks.VerifiedROBlob
166
+ expectedBlobCount int
167
+ }{
168
+ {
169
+ name : "Constructed 0 blobs" ,
170
+ blobSidecars : nil ,
171
+ expectedBlobCount : 0 ,
176
172
},
177
- expectedBlobCount : 6 ,
178
- },
179
- }
173
+ {
174
+ name : "Constructed 6 blobs" ,
175
+ blobSidecars : []blocks.VerifiedROBlob {
176
+ {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob }, {ROBlob : rob },
177
+ },
178
+ expectedBlobCount : 6 ,
179
+ },
180
+ }
180
181
181
- for _ , tt := range tests {
182
- t .Run (tt .name , func (t * testing.T ) {
183
- s := Service {
184
- cfg : & config {
185
- p2p : mockp2p .NewTestP2P (t ),
186
- chain : chainService ,
187
- clock : startup .NewClock (time .Now (), [32 ]byte {}),
188
- blobStorage : filesystem .NewEphemeralBlobStorage (t ),
189
- executionReconstructor : & mockExecution.EngineClient {
190
- BlobSidecars : tt .blobSidecars ,
182
+ for _ , tt := range tests {
183
+ t .Run (tt .name , func (t * testing.T ) {
184
+ s := Service {
185
+ cfg : & config {
186
+ p2p : mockp2p .NewTestP2P (t ),
187
+ chain : chainService ,
188
+ clock : startup .NewClock (time .Now (), [32 ]byte {}),
189
+ blobStorage : filesystem .NewEphemeralBlobStorage (t ),
190
+ executionReconstructor : & mockExecution.EngineClient {
191
+ BlobSidecars : tt .blobSidecars ,
192
+ },
193
+ operationNotifier : & chainMock.MockOperationNotifier {},
191
194
},
192
- operationNotifier : & chainMock.MockOperationNotifier {},
193
- },
194
- seenBlobCache : lruwrpr .New (1 ),
195
- }
196
- s .reconstructAndBroadcastBlobs (context .Background (), sb )
197
- require .Equal (t , tt .expectedBlobCount , len (chainService .Blobs ))
198
- })
199
- }
200
- }
195
+ seenBlobCache : lruwrpr .New (1 ),
196
+ }
197
+ s .reconstructAndBroadcastBlobs (context .Background (), sb )
198
+ require .Equal (t , tt .expectedBlobCount , len (chainService .Blobs ))
199
+ })
200
+ }
201
+ })
201
202
202
- func TestReconstructAndBroadcastDataColumns (t * testing.T ) {
203
- // load trusted setup
204
- err := kzg .Start ()
205
- require .NoError (t , err )
203
+ t . Run ( "data columns" , func (t * testing.T ) {
204
+ // load trusted setup
205
+ err := kzg .Start ()
206
+ require .NoError (t , err )
206
207
207
- // Setup right fork epoch
208
- params .SetupTestConfigCleanup (t )
209
- cfg := params .BeaconConfig ().Copy ()
210
- cfg .CapellaForkEpoch = 0
211
- cfg .DenebForkEpoch = 0
212
- cfg .ElectraForkEpoch = 0
213
- cfg .FuluForkEpoch = 0
214
- params .OverrideBeaconConfig (cfg )
208
+ // Setup right fork epoch
209
+ params .SetupTestConfigCleanup (t )
210
+ cfg := params .BeaconConfig ().Copy ()
211
+ cfg .CapellaForkEpoch = 0
212
+ cfg .DenebForkEpoch = 0
213
+ cfg .ElectraForkEpoch = 0
214
+ cfg .FuluForkEpoch = 0
215
+ params .OverrideBeaconConfig (cfg )
215
216
216
- chainService := & chainMock.ChainService {
217
- Genesis : time .Now (),
218
- }
217
+ chainService := & chainMock.ChainService {
218
+ Genesis : time .Now (),
219
+ }
219
220
220
- b := util .NewBeaconBlockFulu ()
221
- sb , err := blocks .NewSignedBeaconBlock (b )
222
- require .NoError (t , err )
221
+ b := util .NewBeaconBlockFulu ()
222
+ sb , err := blocks .NewSignedBeaconBlock (b )
223
+ require .NoError (t , err )
223
224
224
- allColumns := make ([]blocks.VerifiedRODataColumn , 128 )
225
- for i := range allColumns {
226
- rod , err := blocks .NewRODataColumn (
227
- & ethpb.DataColumnSidecar {
228
- SignedBlockHeader : & ethpb.SignedBeaconBlockHeader {
229
- Header : & ethpb.BeaconBlockHeader {
230
- ParentRoot : make ([]byte , 32 ),
231
- BodyRoot : make ([]byte , 32 ),
232
- StateRoot : make ([]byte , 32 ),
233
- ProposerIndex : primitives .ValidatorIndex (123 ),
234
- Slot : primitives .Slot (123 ),
225
+ allColumns := make ([]blocks.VerifiedRODataColumn , 128 )
226
+ for i := range allColumns {
227
+ rod , err := blocks .NewRODataColumn (
228
+ & ethpb.DataColumnSidecar {
229
+ SignedBlockHeader : & ethpb.SignedBeaconBlockHeader {
230
+ Header : & ethpb.BeaconBlockHeader {
231
+ ParentRoot : make ([]byte , 32 ),
232
+ BodyRoot : make ([]byte , 32 ),
233
+ StateRoot : make ([]byte , 32 ),
234
+ ProposerIndex : primitives .ValidatorIndex (123 ),
235
+ Slot : primitives .Slot (123 ),
236
+ },
237
+ Signature : []byte ("signature" ),
235
238
},
236
- Signature : []byte ("signature" ),
237
- },
238
- ColumnIndex : uint64 (i ),
239
- })
240
- require .NoError (t , err )
241
- allColumns [i ] = blocks.VerifiedRODataColumn {RODataColumn : rod }
242
- }
243
- tests := []struct {
244
- name string
245
- dataColumnSidecars []blocks.VerifiedRODataColumn
246
- expectedDataColumnCount int
247
- }{
248
- {
249
- name : "Constructed 0 data columns with no blobs" ,
250
- dataColumnSidecars : nil ,
251
- expectedDataColumnCount : 0 ,
252
- },
253
- {
254
- name : "Constructed 128 data columns with all blobs" ,
255
- dataColumnSidecars : allColumns ,
256
- expectedDataColumnCount : 8 , // default is 8
257
- },
258
- }
239
+ ColumnIndex : uint64 (i ),
240
+ })
241
+ require .NoError (t , err )
242
+ allColumns [i ] = blocks.VerifiedRODataColumn {RODataColumn : rod }
243
+ }
244
+ tests := []struct {
245
+ name string
246
+ dataColumnSidecars []blocks.VerifiedRODataColumn
247
+ expectedDataColumnCount int
248
+ }{
249
+ {
250
+ name : "Constructed 0 data columns with no blobs" ,
251
+ dataColumnSidecars : nil ,
252
+ expectedDataColumnCount : 0 ,
253
+ },
254
+ {
255
+ name : "Constructed 128 data columns with all blobs" ,
256
+ dataColumnSidecars : allColumns ,
257
+ expectedDataColumnCount : 8 , // default is 8
258
+ },
259
+ }
259
260
260
- for _ , tt := range tests {
261
- t .Run (tt .name , func (t * testing.T ) {
262
- s := Service {
263
- cfg : & config {
264
- p2p : mockp2p .NewTestP2P (t ),
265
- chain : chainService ,
266
- clock : startup .NewClock (time .Now (), [32 ]byte {}),
267
- blobStorage : filesystem .NewEphemeralBlobStorage (t ),
268
- executionReconstructor : & mockExecution.EngineClient {
269
- DataColumnSidecars : tt .dataColumnSidecars ,
261
+ for _ , tt := range tests {
262
+ t .Run (tt .name , func (t * testing.T ) {
263
+ s := Service {
264
+ cfg : & config {
265
+ p2p : mockp2p .NewTestP2P (t ),
266
+ chain : chainService ,
267
+ clock : startup .NewClock (time .Now (), [32 ]byte {}),
268
+ blobStorage : filesystem .NewEphemeralBlobStorage (t ),
269
+ executionReconstructor : & mockExecution.EngineClient {
270
+ DataColumnSidecars : tt .dataColumnSidecars ,
271
+ },
272
+ operationNotifier : & chainMock.MockOperationNotifier {},
273
+ custodyInfo : & peerdas.CustodyInfo {},
270
274
},
271
- operationNotifier : & chainMock.MockOperationNotifier {},
272
- custodyInfo : & peerdas.CustodyInfo {},
273
- },
274
- seenDataColumnCache : lruwrpr .New (1 ),
275
- receivedDataColumnsFromRoot : gcache .New (1 * time .Minute , 2 * time .Minute ),
276
- storedDataColumnsFromRoot : gcache .New (1 * time .Minute , 2 * time .Minute ),
277
- }
278
- s .reconstructAndBroadcastBlobs (context .Background (), sb )
279
- require .Equal (t , tt .expectedDataColumnCount , len (chainService .DataColumns ))
280
- })
281
- }
275
+ seenDataColumnCache : lruwrpr .New (1 ),
276
+ receivedDataColumnsFromRoot : gcache .New (1 * time .Minute , 2 * time .Minute ),
277
+ storedDataColumnsFromRoot : gcache .New (1 * time .Minute , 2 * time .Minute ),
278
+ }
279
+ s .reconstructAndBroadcastBlobs (context .Background (), sb )
280
+ require .Equal (t , tt .expectedDataColumnCount , len (chainService .DataColumns ))
281
+ })
282
+ }
283
+ })
284
+
282
285
}
0 commit comments