@@ -609,74 +609,68 @@ func TestVerifyExtra(t *testing.T) {
609
609
}
610
610
}
611
611
612
- func TestPredicateBytesFromExtra (t * testing.T ) {
612
+ func TestPredicateBytesExtra (t * testing.T ) {
613
613
tests := []struct {
614
- name string
615
- rules extras.AvalancheRules
616
- extra []byte
617
- expected []byte
614
+ name string
615
+ rules extras.AvalancheRules
616
+ extra []byte
617
+ predicate []byte
618
+ wantExtraWithPredicate []byte
619
+ wantPredicateBytes []byte
618
620
}{
619
621
{
620
- name : "empty_extra" ,
621
- extra : nil ,
622
- expected : nil ,
623
- },
624
- {
625
- name : "too_short" ,
626
- extra : make ([]byte , ap3 .WindowSize - 1 ),
627
- expected : nil ,
628
- },
629
- {
630
- name : "empty_predicate" ,
631
- extra : make ([]byte , ap3 .WindowSize ),
632
- expected : nil ,
633
- },
634
- {
635
- name : "non_empty_predicate" ,
636
- extra : []byte {
637
- ap3 .WindowSize : 5 ,
638
- },
639
- expected : []byte {5 },
622
+ name : "empty_extra_predicate" ,
623
+ extra : nil ,
624
+ predicate : nil ,
625
+ wantExtraWithPredicate : make ([]byte , ap3 .WindowSize ),
626
+ wantPredicateBytes : nil ,
640
627
},
641
628
{
642
- name : "fortuna_empty_extra " ,
629
+ name : "empty_extra_predicate_fortuna " ,
643
630
rules : extras.AvalancheRules {
644
631
IsFortuna : true ,
645
632
},
646
- extra : nil ,
647
- expected : nil ,
633
+ extra : nil ,
634
+ predicate : nil ,
635
+ wantExtraWithPredicate : make ([]byte , acp176 .StateSize ),
636
+ wantPredicateBytes : nil ,
648
637
},
649
638
{
650
- name : "fortuna_too_short" ,
651
- rules : extras.AvalancheRules {
652
- IsFortuna : true ,
639
+ name : "extra_too_short" ,
640
+ extra : []byte {
641
+ 0 : 1 ,
642
+ ap3 .WindowSize - 1 : 0 ,
653
643
},
654
- extra : make ([]byte , acp176 .StateSize - 1 ),
655
- expected : nil ,
656
- },
657
- {
658
- name : "fortuna_empty_predicate" ,
659
- rules : extras.AvalancheRules {
660
- IsFortuna : true ,
644
+ predicate : []byte {2 },
645
+ wantExtraWithPredicate : []byte {
646
+ 0 : 1 ,
647
+ ap3 .WindowSize : 2 ,
661
648
},
662
- extra : make ([]byte , acp176 .StateSize ),
663
- expected : nil ,
649
+ wantPredicateBytes : []byte {2 },
664
650
},
665
651
{
666
- name : "fortuna_non_empty_predicate " ,
652
+ name : "extra_too_short_fortuna " ,
667
653
rules : extras.AvalancheRules {
668
654
IsFortuna : true ,
669
655
},
670
656
extra : []byte {
671
- acp176 .StateSize : 5 ,
657
+ 0 : 1 ,
658
+ acp176 .StateSize - 1 : 0 ,
659
+ },
660
+ predicate : []byte {2 },
661
+ wantExtraWithPredicate : []byte {
662
+ 0 : 1 ,
663
+ acp176 .StateSize : 2 ,
672
664
},
673
- expected : []byte {5 },
665
+ wantPredicateBytes : []byte {2 },
674
666
},
675
667
}
676
668
for _ , test := range tests {
677
669
t .Run (test .name , func (t * testing.T ) {
678
- got := PredicateBytesFromExtra (test .rules , test .extra )
679
- require .Equal (t , test .expected , got )
670
+ got := SetPredicateBytesInExtra (test .rules , test .extra , test .predicate )
671
+ require .Equal (t , test .wantExtraWithPredicate , got )
672
+ got = PredicateBytesFromExtra (test .rules , test .extra )
673
+ require .Equal (t , test .wantPredicateBytes , got )
680
674
})
681
675
}
682
676
}
@@ -689,17 +683,6 @@ func TestSetPredicateBytesInExtra(t *testing.T) {
689
683
predicate []byte
690
684
want []byte
691
685
}{
692
- {
693
- name : "empty_extra_predicate" ,
694
- want : make ([]byte , ap3 .WindowSize ),
695
- },
696
- {
697
- name : "empty_extra_predicate_fortuna" ,
698
- rules : extras.AvalancheRules {
699
- IsFortuna : true ,
700
- },
701
- want : make ([]byte , acp176 .StateSize ),
702
- },
703
686
{
704
687
name : "extra_too_short" ,
705
688
extra : []byte {1 },
0 commit comments