Merge pull request #1939 from harmony-ek/staking_flag
Add staking mode knob to harmony & node.shpull/1941/head
commit
66493dd3ad
@ -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)) |
||||
} |
@ -1,28 +0,0 @@ |
||||
package utils |
||||
|
||||
import ( |
||||
"fmt" |
||||
"testing" |
||||
) |
||||
|
||||
func TestStringsToAddrs(t *testing.T) { |
||||
bn, err := StringsToAddrs(DefaultBootNodeAddrStrings) |
||||
if err != nil { |
||||
t.Fatalf("unable to convert string to addresses: %v", err) |
||||
} |
||||
if len(bn) == 0 { |
||||
t.Fatalf("should have more than one multiaddress returned") |
||||
} |
||||
} |
||||
|
||||
func TestAddrListFunc(t *testing.T) { |
||||
addr := new(AddrList) |
||||
err := addr.Set("/ip4/127.0.0.1/tcp/9999/p2p/QmayB8NwxmfGE4Usb4H61M8uwbfc7LRbmXb3ChseJgbVuf,/ip4/127.0.0.1/tcp/9877/p2p/QmS374uzJ9yEEoWcEQ6JcbSUaVUj29SKakcmVvr3HVAjKP") |
||||
if err != nil || len(*addr) < 2 { |
||||
t.Fatalf("unable to set addr list") |
||||
} |
||||
s := fmt.Sprintf("addr: %s\n", addr) |
||||
if len(s) == 0 { |
||||
t.Fatalf("unable to print AddrList") |
||||
} |
||||
} |
@ -1,4 +1,4 @@ |
||||
package utils |
||||
package p2putils |
||||
|
||||
import ( |
||||
"fmt" |
@ -0,0 +1,67 @@ |
||||
package p2putils |
||||
|
||||
import ( |
||||
"fmt" |
||||
"reflect" |
||||
"testing" |
||||
|
||||
"github.com/harmony-one/harmony/p2p" |
||||
) |
||||
|
||||
func TestStringsToAddrs(t *testing.T) { |
||||
bn, err := StringsToAddrs(DefaultBootNodeAddrStrings) |
||||
if err != nil { |
||||
t.Fatalf("unable to convert string to addresses: %v", err) |
||||
} |
||||
if len(bn) == 0 { |
||||
t.Fatalf("should have more than one multiaddress returned") |
||||
} |
||||
} |
||||
|
||||
func TestAddrListFunc(t *testing.T) { |
||||
addr := new(AddrList) |
||||
err := addr.Set("/ip4/127.0.0.1/tcp/9999/p2p/QmayB8NwxmfGE4Usb4H61M8uwbfc7LRbmXb3ChseJgbVuf,/ip4/127.0.0.1/tcp/9877/p2p/QmS374uzJ9yEEoWcEQ6JcbSUaVUj29SKakcmVvr3HVAjKP") |
||||
if err != nil || len(*addr) < 2 { |
||||
t.Fatalf("unable to set addr list") |
||||
} |
||||
s := fmt.Sprintf("addr: %s\n", addr) |
||||
if len(s) == 0 { |
||||
t.Fatalf("unable to print AddrList") |
||||
} |
||||
} |
||||
|
||||
func TestStringsToPeers(t *testing.T) { |
||||
tests := []struct { |
||||
input string |
||||
expected []p2p.Peer |
||||
}{ |
||||
{ |
||||
"127.0.0.1:9000,192.168.192.1:8888,54.32.12.3:9898", |
||||
[]p2p.Peer{ |
||||
{IP: "127.0.0.1", Port: "9000"}, |
||||
{IP: "192.168.192.1", Port: "8888"}, |
||||
{IP: "54.32.12.3", Port: "9898"}, |
||||
}, |
||||
}, |
||||
{ |
||||
"a:b,xx:XX,hello:world", |
||||
[]p2p.Peer{ |
||||
{IP: "a", Port: "b"}, |
||||
{IP: "xx", Port: "XX"}, |
||||
{IP: "hello", Port: "world"}, |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
for _, test := range tests { |
||||
peers := StringsToPeers(test.input) |
||||
if len(peers) != 3 { |
||||
t.Errorf("StringsToPeers failure") |
||||
} |
||||
for i, p := range peers { |
||||
if !reflect.DeepEqual(p, test.expected[i]) { |
||||
t.Errorf("StringToPeers: expected: %v, got: %v", test.expected[i], p) |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue