@@ -624,203 +624,6 @@ func TestDARetriever_RetrieveForcedIncludedTxsFromDA_ExceedsMaxBlobSize(t *testi
624624 assert .Greater (t , totalSizeWithThird , int (common .DefaultMaxBlobSize ))
625625}
626626
627- func TestDARetriever_CalculateEpochNumber (t * testing.T ) {
628- tests := []struct {
629- name string
630- daStartHeight uint64
631- daEpochSize uint64
632- daHeight uint64
633- expectedEpoch uint64
634- }{
635- {
636- name : "first epoch - start height" ,
637- daStartHeight : 100 ,
638- daEpochSize : 10 ,
639- daHeight : 100 ,
640- expectedEpoch : 1 ,
641- },
642- {
643- name : "first epoch - middle" ,
644- daStartHeight : 100 ,
645- daEpochSize : 10 ,
646- daHeight : 105 ,
647- expectedEpoch : 1 ,
648- },
649- {
650- name : "first epoch - last height" ,
651- daStartHeight : 100 ,
652- daEpochSize : 10 ,
653- daHeight : 109 ,
654- expectedEpoch : 1 ,
655- },
656- {
657- name : "second epoch - start" ,
658- daStartHeight : 100 ,
659- daEpochSize : 10 ,
660- daHeight : 110 ,
661- expectedEpoch : 2 ,
662- },
663- {
664- name : "second epoch - middle" ,
665- daStartHeight : 100 ,
666- daEpochSize : 10 ,
667- daHeight : 115 ,
668- expectedEpoch : 2 ,
669- },
670- {
671- name : "tenth epoch" ,
672- daStartHeight : 100 ,
673- daEpochSize : 10 ,
674- daHeight : 195 ,
675- expectedEpoch : 10 ,
676- },
677- {
678- name : "before start height" ,
679- daStartHeight : 100 ,
680- daEpochSize : 10 ,
681- daHeight : 50 ,
682- expectedEpoch : 0 ,
683- },
684- {
685- name : "zero epoch size" ,
686- daStartHeight : 100 ,
687- daEpochSize : 0 ,
688- daHeight : 200 ,
689- expectedEpoch : 1 ,
690- },
691- {
692- name : "large epoch size" ,
693- daStartHeight : 1000 ,
694- daEpochSize : 1000 ,
695- daHeight : 2500 ,
696- expectedEpoch : 2 ,
697- },
698- }
699-
700- for _ , tt := range tests {
701- t .Run (tt .name , func (t * testing.T ) {
702- ds := dssync .MutexWrap (datastore .NewMapDatastore ())
703- st := store .New (ds )
704- cm , err := cache .NewManager (config .DefaultConfig (), st , zerolog .Nop ())
705- require .NoError (t , err )
706-
707- mockDA := testmocks .NewMockDA (t )
708- gen := genesis.Genesis {DAStartHeight : tt .daStartHeight }
709- cfg := config .DefaultConfig ()
710- cfg .DA .ForcedInclusionDAEpoch = tt .daEpochSize
711-
712- r := NewDARetriever (mockDA , cm , cfg , gen , zerolog .Nop ())
713- epoch := r .calculateEpochNumber (tt .daHeight )
714-
715- assert .Equal (t , tt .expectedEpoch , epoch )
716- })
717- }
718- }
719-
720- func TestDARetriever_CalculateEpochBoundaries (t * testing.T ) {
721- tests := []struct {
722- name string
723- daStartHeight uint64
724- daEpochSize uint64
725- daHeight uint64
726- expectedStart uint64
727- expectedEnd uint64
728- }{
729- {
730- name : "first epoch" ,
731- daStartHeight : 100 ,
732- daEpochSize : 10 ,
733- daHeight : 105 ,
734- expectedStart : 100 ,
735- expectedEnd : 109 ,
736- },
737- {
738- name : "second epoch" ,
739- daStartHeight : 100 ,
740- daEpochSize : 10 ,
741- daHeight : 110 ,
742- expectedStart : 110 ,
743- expectedEnd : 119 ,
744- },
745- {
746- name : "third epoch - last height" ,
747- daStartHeight : 100 ,
748- daEpochSize : 10 ,
749- daHeight : 129 ,
750- expectedStart : 120 ,
751- expectedEnd : 129 ,
752- },
753- {
754- name : "before start height returns first epoch" ,
755- daStartHeight : 100 ,
756- daEpochSize : 10 ,
757- daHeight : 50 ,
758- expectedStart : 100 ,
759- expectedEnd : 109 ,
760- },
761- {
762- name : "zero epoch size" ,
763- daStartHeight : 100 ,
764- daEpochSize : 0 ,
765- daHeight : 200 ,
766- expectedStart : 100 ,
767- expectedEnd : 100 ,
768- },
769- {
770- name : "large epoch" ,
771- daStartHeight : 1000 ,
772- daEpochSize : 1000 ,
773- daHeight : 1500 ,
774- expectedStart : 1000 ,
775- expectedEnd : 1999 ,
776- },
777- {
778- name : "epoch boundary exact start" ,
779- daStartHeight : 100 ,
780- daEpochSize : 50 ,
781- daHeight : 100 ,
782- expectedStart : 100 ,
783- expectedEnd : 149 ,
784- },
785- {
786- name : "epoch boundary exact end of first epoch" ,
787- daStartHeight : 100 ,
788- daEpochSize : 50 ,
789- daHeight : 149 ,
790- expectedStart : 100 ,
791- expectedEnd : 149 ,
792- },
793- {
794- name : "epoch boundary exact start of second epoch" ,
795- daStartHeight : 100 ,
796- daEpochSize : 50 ,
797- daHeight : 150 ,
798- expectedStart : 150 ,
799- expectedEnd : 199 ,
800- },
801- }
802-
803- for _ , tt := range tests {
804- t .Run (tt .name , func (t * testing.T ) {
805- ds := dssync .MutexWrap (datastore .NewMapDatastore ())
806- st := store .New (ds )
807- cm , err := cache .NewManager (config .DefaultConfig (), st , zerolog .Nop ())
808- require .NoError (t , err )
809-
810- mockDA := testmocks .NewMockDA (t )
811- gen := genesis.Genesis {DAStartHeight : tt .daStartHeight }
812- cfg := config .DefaultConfig ()
813- cfg .DA .ForcedInclusionDAEpoch = tt .daEpochSize
814-
815- r := NewDARetriever (mockDA , cm , cfg , gen , zerolog .Nop ())
816- start , end := r .calculateEpochBoundaries (tt .daHeight )
817-
818- assert .Equal (t , tt .expectedStart , start , "start height mismatch" )
819- assert .Equal (t , tt .expectedEnd , end , "end height mismatch" )
820- })
821- }
822- }
823-
824627func TestDARetriever_RetrieveForcedIncludedTxsFromDA_NotAtEpochStart (t * testing.T ) {
825628 ds := dssync .MutexWrap (datastore .NewMapDatastore ())
826629 st := store .New (ds )
0 commit comments