@@ -248,78 +248,41 @@ func TestVerifyExtra(t *testing.T) {
248248 }
249249}
250250
251- func TestPredicateBytesFromExtra (t * testing.T ) {
251+ func TestPredicateBytesExtra (t * testing.T ) {
252252 tests := []struct {
253- name string
254- extra []byte
255- expected []byte
253+ name string
254+ extra []byte
255+ predicate []byte
256+ wantExtraWithPredicate []byte
257+ wantPredicateBytes []byte
256258 }{
257259 {
258- name : "empty_extra" ,
259- extra : nil ,
260- expected : nil ,
261- },
262- {
263- name : "too_short" ,
264- extra : make ([]byte , subnetevm .WindowSize - 1 ),
265- expected : nil ,
266- },
267- {
268- name : "empty_predicate" ,
269- extra : make ([]byte , subnetevm .WindowSize ),
270- expected : nil ,
260+ name : "empty_extra_predicate" ,
261+ extra : nil ,
262+ predicate : nil ,
263+ wantExtraWithPredicate : make ([]byte , subnetevm .WindowSize ),
264+ wantPredicateBytes : nil ,
271265 },
272266 {
273- name : "non_empty_predicate " ,
267+ name : "extra_too_short " ,
274268 extra : []byte {
275- subnetevm .WindowSize : 5 ,
269+ 0 : 1 ,
270+ subnetevm .WindowSize - 1 : 0 ,
276271 },
277- expected : []byte {5 },
278- },
279- }
280- for _ , test := range tests {
281- t .Run (test .name , func (t * testing.T ) {
282- got := PredicateBytesFromExtra (test .extra )
283- require .Equal (t , test .expected , got )
284- })
285- }
286- }
287-
288- func TestSetPredicateBytesInExtra (t * testing.T ) {
289- tests := []struct {
290- name string
291- extra []byte
292- predicate []byte
293- want []byte
294- }{
295- {
296- name : "empty_extra_predicate" ,
297- want : make ([]byte , subnetevm .WindowSize ),
298- },
299- {
300- name : "extra_too_short" ,
301- extra : []byte {1 },
302272 predicate : []byte {2 },
303- want : []byte {
273+ wantExtraWithPredicate : []byte {
304274 0 : 1 ,
305275 subnetevm .WindowSize : 2 ,
306276 },
307- },
308- {
309- name : "extra_too_long" ,
310- extra : []byte {
311- subnetevm .WindowSize : 1 ,
312- },
313- predicate : []byte {2 },
314- want : []byte {
315- subnetevm .WindowSize : 2 ,
316- },
277+ wantPredicateBytes : []byte {2 },
317278 },
318279 }
319280 for _ , test := range tests {
320281 t .Run (test .name , func (t * testing.T ) {
321- got := SetPredicateBytesInExtra (test .extra , test .predicate )
322- require .Equal (t , test .want , got )
282+ gotExtra := SetPredicateBytesInExtra (test .extra , test .predicate )
283+ require .Equal (t , test .wantExtraWithPredicate , gotExtra )
284+ gotPredicateBytes := PredicateBytesFromExtra (gotExtra )
285+ require .Equal (t , test .wantPredicateBytes , gotPredicateBytes )
323286 })
324287 }
325288}
0 commit comments