From 9d0cc6196a877d9c39d951c12a51aaf4130df2ec Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Mon, 2 Dec 2019 16:21:43 -0800 Subject: [PATCH] Mock shardingconfig interfaces To be used by UTs. --- .../configs/sharding/mock/shardingconfig.go | 298 ++++++++++++++++++ internal/configs/sharding/shardingconfig.go | 2 + 2 files changed, 300 insertions(+) create mode 100644 internal/configs/sharding/mock/shardingconfig.go diff --git a/internal/configs/sharding/mock/shardingconfig.go b/internal/configs/sharding/mock/shardingconfig.go new file mode 100644 index 000000000..946c8ddb7 --- /dev/null +++ b/internal/configs/sharding/mock/shardingconfig.go @@ -0,0 +1,298 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: shardingconfig.go + +// Package mock_shardingconfig is a generated GoMock package. +package mock_shardingconfig + +import ( + gomock "github.com/golang/mock/gomock" + sharding "github.com/harmony-one/harmony/internal/configs/sharding" + genesis "github.com/harmony-one/harmony/internal/genesis" + big "math/big" + reflect "reflect" +) + +// MockSchedule is a mock of Schedule interface +type MockSchedule struct { + ctrl *gomock.Controller + recorder *MockScheduleMockRecorder +} + +// MockScheduleMockRecorder is the mock recorder for MockSchedule +type MockScheduleMockRecorder struct { + mock *MockSchedule +} + +// NewMockSchedule creates a new mock instance +func NewMockSchedule(ctrl *gomock.Controller) *MockSchedule { + mock := &MockSchedule{ctrl: ctrl} + mock.recorder = &MockScheduleMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockSchedule) EXPECT() *MockScheduleMockRecorder { + return m.recorder +} + +// InstanceForEpoch mocks base method +func (m *MockSchedule) InstanceForEpoch(epoch *big.Int) sharding.Instance { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InstanceForEpoch", epoch) + ret0, _ := ret[0].(sharding.Instance) + return ret0 +} + +// InstanceForEpoch indicates an expected call of InstanceForEpoch +func (mr *MockScheduleMockRecorder) InstanceForEpoch(epoch interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstanceForEpoch", reflect.TypeOf((*MockSchedule)(nil).InstanceForEpoch), epoch) +} + +// BlocksPerEpoch mocks base method +func (m *MockSchedule) BlocksPerEpoch() uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlocksPerEpoch") + ret0, _ := ret[0].(uint64) + return ret0 +} + +// BlocksPerEpoch indicates an expected call of BlocksPerEpoch +func (mr *MockScheduleMockRecorder) BlocksPerEpoch() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksPerEpoch", reflect.TypeOf((*MockSchedule)(nil).BlocksPerEpoch)) +} + +// CalcEpochNumber mocks base method +func (m *MockSchedule) CalcEpochNumber(blockNum uint64) *big.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CalcEpochNumber", blockNum) + ret0, _ := ret[0].(*big.Int) + return ret0 +} + +// CalcEpochNumber indicates an expected call of CalcEpochNumber +func (mr *MockScheduleMockRecorder) CalcEpochNumber(blockNum interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CalcEpochNumber", reflect.TypeOf((*MockSchedule)(nil).CalcEpochNumber), blockNum) +} + +// IsLastBlock mocks base method +func (m *MockSchedule) IsLastBlock(blockNum uint64) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsLastBlock", blockNum) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsLastBlock indicates an expected call of IsLastBlock +func (mr *MockScheduleMockRecorder) IsLastBlock(blockNum interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsLastBlock", reflect.TypeOf((*MockSchedule)(nil).IsLastBlock), blockNum) +} + +// EpochLastBlock mocks base method +func (m *MockSchedule) EpochLastBlock(epochNum uint64) uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EpochLastBlock", epochNum) + ret0, _ := ret[0].(uint64) + return ret0 +} + +// EpochLastBlock indicates an expected call of EpochLastBlock +func (mr *MockScheduleMockRecorder) EpochLastBlock(epochNum interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EpochLastBlock", reflect.TypeOf((*MockSchedule)(nil).EpochLastBlock), epochNum) +} + +// VdfDifficulty mocks base method +func (m *MockSchedule) VdfDifficulty() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VdfDifficulty") + ret0, _ := ret[0].(int) + return ret0 +} + +// VdfDifficulty indicates an expected call of VdfDifficulty +func (mr *MockScheduleMockRecorder) VdfDifficulty() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VdfDifficulty", reflect.TypeOf((*MockSchedule)(nil).VdfDifficulty)) +} + +// ConsensusRatio mocks base method +func (m *MockSchedule) ConsensusRatio() float64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConsensusRatio") + ret0, _ := ret[0].(float64) + return ret0 +} + +// ConsensusRatio indicates an expected call of ConsensusRatio +func (mr *MockScheduleMockRecorder) ConsensusRatio() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsensusRatio", reflect.TypeOf((*MockSchedule)(nil).ConsensusRatio)) +} + +// RandomnessStartingEpoch mocks base method +func (m *MockSchedule) RandomnessStartingEpoch() uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RandomnessStartingEpoch") + ret0, _ := ret[0].(uint64) + return ret0 +} + +// RandomnessStartingEpoch indicates an expected call of RandomnessStartingEpoch +func (mr *MockScheduleMockRecorder) RandomnessStartingEpoch() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RandomnessStartingEpoch", reflect.TypeOf((*MockSchedule)(nil).RandomnessStartingEpoch)) +} + +// GetNetworkID mocks base method +func (m *MockSchedule) GetNetworkID() sharding.NetworkID { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNetworkID") + ret0, _ := ret[0].(sharding.NetworkID) + return ret0 +} + +// GetNetworkID indicates an expected call of GetNetworkID +func (mr *MockScheduleMockRecorder) GetNetworkID() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkID", reflect.TypeOf((*MockSchedule)(nil).GetNetworkID)) +} + +// GetShardingStructure mocks base method +func (m *MockSchedule) GetShardingStructure(arg0, arg1 int) []map[string]interface{} { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetShardingStructure", arg0, arg1) + ret0, _ := ret[0].([]map[string]interface{}) + return ret0 +} + +// GetShardingStructure indicates an expected call of GetShardingStructure +func (mr *MockScheduleMockRecorder) GetShardingStructure(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetShardingStructure", reflect.TypeOf((*MockSchedule)(nil).GetShardingStructure), arg0, arg1) +} + +// MockInstance is a mock of Instance interface +type MockInstance struct { + ctrl *gomock.Controller + recorder *MockInstanceMockRecorder +} + +// MockInstanceMockRecorder is the mock recorder for MockInstance +type MockInstanceMockRecorder struct { + mock *MockInstance +} + +// NewMockInstance creates a new mock instance +func NewMockInstance(ctrl *gomock.Controller) *MockInstance { + mock := &MockInstance{ctrl: ctrl} + mock.recorder = &MockInstanceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockInstance) EXPECT() *MockInstanceMockRecorder { + return m.recorder +} + +// NumShards mocks base method +func (m *MockInstance) NumShards() uint32 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NumShards") + ret0, _ := ret[0].(uint32) + return ret0 +} + +// NumShards indicates an expected call of NumShards +func (mr *MockInstanceMockRecorder) NumShards() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NumShards", reflect.TypeOf((*MockInstance)(nil).NumShards)) +} + +// NumNodesPerShard mocks base method +func (m *MockInstance) NumNodesPerShard() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NumNodesPerShard") + ret0, _ := ret[0].(int) + return ret0 +} + +// NumNodesPerShard indicates an expected call of NumNodesPerShard +func (mr *MockInstanceMockRecorder) NumNodesPerShard() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NumNodesPerShard", reflect.TypeOf((*MockInstance)(nil).NumNodesPerShard)) +} + +// NumHarmonyOperatedNodesPerShard mocks base method +func (m *MockInstance) NumHarmonyOperatedNodesPerShard() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NumHarmonyOperatedNodesPerShard") + ret0, _ := ret[0].(int) + return ret0 +} + +// NumHarmonyOperatedNodesPerShard indicates an expected call of NumHarmonyOperatedNodesPerShard +func (mr *MockInstanceMockRecorder) NumHarmonyOperatedNodesPerShard() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NumHarmonyOperatedNodesPerShard", reflect.TypeOf((*MockInstance)(nil).NumHarmonyOperatedNodesPerShard)) +} + +// HmyAccounts mocks base method +func (m *MockInstance) HmyAccounts() []genesis.DeployAccount { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HmyAccounts") + ret0, _ := ret[0].([]genesis.DeployAccount) + return ret0 +} + +// HmyAccounts indicates an expected call of HmyAccounts +func (mr *MockInstanceMockRecorder) HmyAccounts() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HmyAccounts", reflect.TypeOf((*MockInstance)(nil).HmyAccounts)) +} + +// FnAccounts mocks base method +func (m *MockInstance) FnAccounts() []genesis.DeployAccount { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FnAccounts") + ret0, _ := ret[0].([]genesis.DeployAccount) + return ret0 +} + +// FnAccounts indicates an expected call of FnAccounts +func (mr *MockInstanceMockRecorder) FnAccounts() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FnAccounts", reflect.TypeOf((*MockInstance)(nil).FnAccounts)) +} + +// FindAccount mocks base method +func (m *MockInstance) FindAccount(blsPubKey string) (bool, *genesis.DeployAccount) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindAccount", blsPubKey) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(*genesis.DeployAccount) + return ret0, ret1 +} + +// FindAccount indicates an expected call of FindAccount +func (mr *MockInstanceMockRecorder) FindAccount(blsPubKey interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAccount", reflect.TypeOf((*MockInstance)(nil).FindAccount), blsPubKey) +} + +// ReshardingEpoch mocks base method +func (m *MockInstance) ReshardingEpoch() []*big.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReshardingEpoch") + ret0, _ := ret[0].([]*big.Int) + return ret0 +} + +// ReshardingEpoch indicates an expected call of ReshardingEpoch +func (mr *MockInstanceMockRecorder) ReshardingEpoch() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReshardingEpoch", reflect.TypeOf((*MockInstance)(nil).ReshardingEpoch)) +} diff --git a/internal/configs/sharding/shardingconfig.go b/internal/configs/sharding/shardingconfig.go index d46c9eaeb..7453cdf67 100644 --- a/internal/configs/sharding/shardingconfig.go +++ b/internal/configs/sharding/shardingconfig.go @@ -9,6 +9,8 @@ import ( "github.com/harmony-one/harmony/internal/genesis" ) +//go:generate mockgen -source=shardingconfig.go -destination=mock/shardingconfig.go + // Schedule returns the sharding configuration instance for the given // epoch. type Schedule interface {