fix mocks generation and remove reflection

This commit is contained in:
marcello33 2025-03-26 15:18:43 +01:00
parent 8a55299877
commit 131b413fd9
No known key found for this signature in database
GPG key ID: 06128777E3C36B16
4 changed files with 41 additions and 55 deletions

View file

@ -34,9 +34,9 @@ protoc:
protoc --go_out=. --go-grpc_out=. ./internal/cli/server/proto/*.proto protoc --go_out=. --go-grpc_out=. ./internal/cli/server/proto/*.proto
generate-mocks: generate-mocks:
go generate mockgen -destination=./tests/bor/mocks/IHeimdallClient.go -package=mocks ./consensus/bor IHeimdallClient go generate ./consensus/bor
go generate mockgen -destination=./eth/filters/IBackend.go -package=filters ./eth/filters Backend go generate ./eth/filters
go generate mockgen -destination=./eth/filters/IDatabase.go -package=filters ./ethdb Database go generate ./ethdb
#? geth: Build geth. #? geth: Build geth.
geth: geth:

View file

@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/bor/heimdall/span" "github.com/ethereum/go-ethereum/consensus/bor/heimdall/span"
) )
//go:generate mockgen -destination=../../tests/bor/mocks/IHeimdallClient.go -package=mocks . IHeimdallClient //go:generate mockgen -source=heimdall.go -destination=../../tests/bor/mocks/IHeimdallClient.go -package=mocks
type IHeimdallClient interface { type IHeimdallClient interface {
StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error)
Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error)

View file

@ -225,20 +225,6 @@ func (mr *MockDatabaseMockRecorder) ItemAmountInAncient() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ItemAmountInAncient", reflect.TypeOf((*MockDatabase)(nil).ItemAmountInAncient)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ItemAmountInAncient", reflect.TypeOf((*MockDatabase)(nil).ItemAmountInAncient))
} }
// MigrateTable mocks base method.
func (m *MockDatabase) MigrateTable(arg0 string, arg1 func([]byte) ([]byte, error)) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MigrateTable", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// MigrateTable indicates an expected call of MigrateTable.
func (mr *MockDatabaseMockRecorder) MigrateTable(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MigrateTable", reflect.TypeOf((*MockDatabase)(nil).MigrateTable), arg0, arg1)
}
// ModifyAncients mocks base method. // ModifyAncients mocks base method.
func (m *MockDatabase) ModifyAncients(arg0 func(ethdb.AncientWriteOp) error) (int64, error) { func (m *MockDatabase) ModifyAncients(arg0 func(ethdb.AncientWriteOp) error) (int64, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()

View file

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT. // Code generated by MockGen. DO NOT EDIT.
// Source: github.com/ethereum/go-ethereum/consensus/bor (interfaces: IHeimdallClient) // Source: heimdall.go
// Package mocks is a generated GoMock package. // Package mocks is a generated GoMock package.
package mocks package mocks
@ -51,134 +51,134 @@ func (mr *MockIHeimdallClientMockRecorder) Close() *gomock.Call {
} }
// FetchCheckpoint mocks base method. // FetchCheckpoint mocks base method.
func (m *MockIHeimdallClient) FetchCheckpoint(arg0 context.Context, arg1 int64) (*checkpoint.Checkpoint, error) { func (m *MockIHeimdallClient) FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchCheckpoint", arg0, arg1) ret := m.ctrl.Call(m, "FetchCheckpoint", ctx, number)
ret0, _ := ret[0].(*checkpoint.Checkpoint) ret0, _ := ret[0].(*checkpoint.Checkpoint)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// FetchCheckpoint indicates an expected call of FetchCheckpoint. // FetchCheckpoint indicates an expected call of FetchCheckpoint.
func (mr *MockIHeimdallClientMockRecorder) FetchCheckpoint(arg0, arg1 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchCheckpoint(ctx, number interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoint", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchCheckpoint), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpoint", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchCheckpoint), ctx, number)
} }
// FetchCheckpointCount mocks base method. // FetchCheckpointCount mocks base method.
func (m *MockIHeimdallClient) FetchCheckpointCount(arg0 context.Context) (int64, error) { func (m *MockIHeimdallClient) FetchCheckpointCount(ctx context.Context) (int64, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchCheckpointCount", arg0) ret := m.ctrl.Call(m, "FetchCheckpointCount", ctx)
ret0, _ := ret[0].(int64) ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// FetchCheckpointCount indicates an expected call of FetchCheckpointCount. // FetchCheckpointCount indicates an expected call of FetchCheckpointCount.
func (mr *MockIHeimdallClientMockRecorder) FetchCheckpointCount(arg0 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchCheckpointCount(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpointCount", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchCheckpointCount), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchCheckpointCount", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchCheckpointCount), ctx)
} }
// FetchLastNoAckMilestone mocks base method. // FetchLastNoAckMilestone mocks base method.
func (m *MockIHeimdallClient) FetchLastNoAckMilestone(arg0 context.Context) (string, error) { func (m *MockIHeimdallClient) FetchLastNoAckMilestone(ctx context.Context) (string, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchLastNoAckMilestone", arg0) ret := m.ctrl.Call(m, "FetchLastNoAckMilestone", ctx)
ret0, _ := ret[0].(string) ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// FetchLastNoAckMilestone indicates an expected call of FetchLastNoAckMilestone. // FetchLastNoAckMilestone indicates an expected call of FetchLastNoAckMilestone.
func (mr *MockIHeimdallClientMockRecorder) FetchLastNoAckMilestone(arg0 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchLastNoAckMilestone(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLastNoAckMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchLastNoAckMilestone), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchLastNoAckMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchLastNoAckMilestone), ctx)
} }
// FetchMilestone mocks base method. // FetchMilestone mocks base method.
func (m *MockIHeimdallClient) FetchMilestone(arg0 context.Context) (*milestone.Milestone, error) { func (m *MockIHeimdallClient) FetchMilestone(ctx context.Context) (*milestone.Milestone, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestone", arg0) ret := m.ctrl.Call(m, "FetchMilestone", ctx)
ret0, _ := ret[0].(*milestone.Milestone) ret0, _ := ret[0].(*milestone.Milestone)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// FetchMilestone indicates an expected call of FetchMilestone. // FetchMilestone indicates an expected call of FetchMilestone.
func (mr *MockIHeimdallClientMockRecorder) FetchMilestone(arg0 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchMilestone(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestone), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestone), ctx)
} }
// FetchMilestoneCount mocks base method. // FetchMilestoneCount mocks base method.
func (m *MockIHeimdallClient) FetchMilestoneCount(arg0 context.Context) (int64, error) { func (m *MockIHeimdallClient) FetchMilestoneCount(ctx context.Context) (int64, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestoneCount", arg0) ret := m.ctrl.Call(m, "FetchMilestoneCount", ctx)
ret0, _ := ret[0].(int64) ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// FetchMilestoneCount indicates an expected call of FetchMilestoneCount. // FetchMilestoneCount indicates an expected call of FetchMilestoneCount.
func (mr *MockIHeimdallClientMockRecorder) FetchMilestoneCount(arg0 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchMilestoneCount(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneCount", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestoneCount), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneCount", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestoneCount), ctx)
} }
// FetchMilestoneID mocks base method. // FetchMilestoneID mocks base method.
func (m *MockIHeimdallClient) FetchMilestoneID(arg0 context.Context, arg1 string) error { func (m *MockIHeimdallClient) FetchMilestoneID(ctx context.Context, milestoneID string) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchMilestoneID", arg0, arg1) ret := m.ctrl.Call(m, "FetchMilestoneID", ctx, milestoneID)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
return ret0 return ret0
} }
// FetchMilestoneID indicates an expected call of FetchMilestoneID. // FetchMilestoneID indicates an expected call of FetchMilestoneID.
func (mr *MockIHeimdallClientMockRecorder) FetchMilestoneID(arg0, arg1 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchMilestoneID(ctx, milestoneID interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneID", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestoneID), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMilestoneID", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchMilestoneID), ctx, milestoneID)
} }
// FetchNoAckMilestone mocks base method. // FetchNoAckMilestone mocks base method.
func (m *MockIHeimdallClient) FetchNoAckMilestone(arg0 context.Context, arg1 string) error { func (m *MockIHeimdallClient) FetchNoAckMilestone(ctx context.Context, milestoneID string) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchNoAckMilestone", arg0, arg1) ret := m.ctrl.Call(m, "FetchNoAckMilestone", ctx, milestoneID)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
return ret0 return ret0
} }
// FetchNoAckMilestone indicates an expected call of FetchNoAckMilestone. // FetchNoAckMilestone indicates an expected call of FetchNoAckMilestone.
func (mr *MockIHeimdallClientMockRecorder) FetchNoAckMilestone(arg0, arg1 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) FetchNoAckMilestone(ctx, milestoneID interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchNoAckMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchNoAckMilestone), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchNoAckMilestone", reflect.TypeOf((*MockIHeimdallClient)(nil).FetchNoAckMilestone), ctx, milestoneID)
} }
// Span mocks base method. // Span mocks base method.
func (m *MockIHeimdallClient) Span(arg0 context.Context, arg1 uint64) (*span.HeimdallSpan, error) { func (m *MockIHeimdallClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Span", arg0, arg1) ret := m.ctrl.Call(m, "Span", ctx, spanID)
ret0, _ := ret[0].(*span.HeimdallSpan) ret0, _ := ret[0].(*span.HeimdallSpan)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// Span indicates an expected call of Span. // Span indicates an expected call of Span.
func (mr *MockIHeimdallClientMockRecorder) Span(arg0, arg1 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) Span(ctx, spanID interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Span", reflect.TypeOf((*MockIHeimdallClient)(nil).Span), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Span", reflect.TypeOf((*MockIHeimdallClient)(nil).Span), ctx, spanID)
} }
// StateSyncEvents mocks base method. // StateSyncEvents mocks base method.
func (m *MockIHeimdallClient) StateSyncEvents(arg0 context.Context, arg1 uint64, arg2 int64) ([]*clerk.EventRecordWithTime, error) { func (m *MockIHeimdallClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateSyncEvents", arg0, arg1, arg2) ret := m.ctrl.Call(m, "StateSyncEvents", ctx, fromID, to)
ret0, _ := ret[0].([]*clerk.EventRecordWithTime) ret0, _ := ret[0].([]*clerk.EventRecordWithTime)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// StateSyncEvents indicates an expected call of StateSyncEvents. // StateSyncEvents indicates an expected call of StateSyncEvents.
func (mr *MockIHeimdallClientMockRecorder) StateSyncEvents(arg0, arg1, arg2 interface{}) *gomock.Call { func (mr *MockIHeimdallClientMockRecorder) StateSyncEvents(ctx, fromID, to interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSyncEvents", reflect.TypeOf((*MockIHeimdallClient)(nil).StateSyncEvents), arg0, arg1, arg2) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSyncEvents", reflect.TypeOf((*MockIHeimdallClient)(nil).StateSyncEvents), ctx, fromID, to)
} }