@@ -985,6 +985,84 @@ func (*AttestationDataProvider) AttestationData(_ context.Context,
985985 }, nil
986986}
987987
988+ // CustomAttestationDataProvider is a mock for eth2client.AttestationDataProvider.
989+ type CustomAttestationDataProvider struct {
990+ changeSlot int
991+ changeRoot bool
992+ }
993+
994+ // NewFuzzingAttestationDataProvider returns a mock attestation data provider.
995+ // changeSlot: how much to add to the slot, 0 for no change, positive for later, negative for earlier.
996+ // changeRoot: whether to change the root based on the slot.
997+ func NewCustomAttestationDataProvider (changeSlot int , changeRoot bool ) eth2client.AttestationDataProvider {
998+ return & CustomAttestationDataProvider {changeSlot : changeSlot , changeRoot : changeRoot }
999+ }
1000+
1001+ // AttestationData is a mock.
1002+ func (m * CustomAttestationDataProvider ) AttestationData (_ context.Context ,
1003+ opts * api.AttestationDataOpts ,
1004+ ) (
1005+ * api.Response [* phase0.AttestationData ],
1006+ error ,
1007+ ) {
1008+ slot := opts .Slot + phase0 .Slot (m .changeSlot )
1009+ // Generate a fixed block root according to the slot.
1010+ firstByte := byte (opts .Slot & 0xff )
1011+ if m .changeRoot {
1012+ firstByte = byte (slot & 0xff )
1013+ }
1014+ beaconBlockRoot := phase0 .Root ([32 ]byte {
1015+ firstByte , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0a , 0x0b , 0x0c , 0x0d , 0x0e , 0x0f ,
1016+ 0x10 , 0x11 , 0x12 , 0x13 , 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1a , 0x1b , 0x1c , 0x1d , 0x1e , 0x1f ,
1017+ })
1018+ source := & phase0.Checkpoint {
1019+ Epoch : phase0 .Epoch (slot / 32 - 1 ),
1020+ Root : phase0 .Root ([32 ]byte {
1021+ firstByte , 0x21 , 0x22 , 0x23 , 0x24 , 0x25 , 0x26 , 0x27 , 0x28 , 0x29 , 0x2a , 0x2b , 0x2c , 0x2d , 0x2e , 0x2f ,
1022+ 0x30 , 0x31 , 0x32 , 0x33 , 0x34 , 0x35 , 0x36 , 0x37 , 0x38 , 0x39 , 0x3a , 0x3b , 0x3c , 0x3d , 0x3e , 0x3f ,
1023+ }),
1024+ }
1025+ target := & phase0.Checkpoint {
1026+ Epoch : phase0 .Epoch (slot / 32 ),
1027+ Root : phase0 .Root ([32 ]byte {
1028+ firstByte , 0x41 , 0x42 , 0x43 , 0x44 , 0x45 , 0x46 , 0x47 , 0x48 , 0x49 , 0x4a , 0x4b , 0x4c , 0x4d , 0x4e , 0x4f ,
1029+ 0x30 , 0x31 , 0x32 , 0x33 , 0x34 , 0x35 , 0x36 , 0x37 , 0x38 , 0x39 , 0x3a , 0x3b , 0x3c , 0x3d , 0x3e , 0x3f ,
1030+ }),
1031+ }
1032+
1033+ return & api.Response [* phase0.AttestationData ]{
1034+ Data : & phase0.AttestationData {
1035+ Slot : slot ,
1036+ Index : opts .CommitteeIndex ,
1037+ BeaconBlockRoot : beaconBlockRoot ,
1038+ Source : source ,
1039+ Target : target ,
1040+ },
1041+ Metadata : make (map [string ]any ),
1042+ }, nil
1043+ }
1044+
1045+ // EmptyAttestationDataProvider is a mock for eth2client.AttestationDataProvider.
1046+ type EmptyAttestationDataProvider struct {}
1047+
1048+ // NewEmptyAttestationDataProvider returns a mock attestation data provider.
1049+ func NewEmptyAttestationDataProvider () eth2client.AttestationDataProvider {
1050+ return & EmptyAttestationDataProvider {}
1051+ }
1052+
1053+ // AttestationData is a mock.
1054+ func (* EmptyAttestationDataProvider ) AttestationData (_ context.Context ,
1055+ opts * api.AttestationDataOpts ,
1056+ ) (
1057+ * api.Response [* phase0.AttestationData ],
1058+ error ,
1059+ ) {
1060+ return & api.Response [* phase0.AttestationData ]{
1061+ Data : & phase0.AttestationData {Slot : opts .Slot },
1062+ Metadata : make (map [string ]any ),
1063+ }, nil
1064+ }
1065+
9881066// ErroringAttestationDataProvider is a mock for eth2client.AttestationDataProvider.
9891067type ErroringAttestationDataProvider struct {}
9901068
0 commit comments