Skip to content

Commit

Permalink
IOTEX-343 Remove numCandidates from config (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjshen14 committed Mar 19, 2019
1 parent 3144f61 commit 071e5c9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 1,022 deletions.
3 changes: 1 addition & 2 deletions blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ func TestBlockchainInitialCandidate(t *testing.T) {
cfg := config.Default
cfg.Chain.TrieDBPath = testTriePath
cfg.Chain.ChainDBPath = testDBPath
cfg.Chain.NumCandidates = 2

sf, err := factory.NewFactory(cfg, factory.DefaultTrieOption())
require.NoError(err)
Expand Down Expand Up @@ -817,7 +816,7 @@ func TestBlockchainInitialCandidate(t *testing.T) {
}()
candidate, err := sf.CandidatesByHeight(0)
require.NoError(err)
require.True(len(candidate) == 2)
require.Equal(24, len(candidate))
}

func TestBlockchain_StateByAddr(t *testing.T) {
Expand Down
11 changes: 0 additions & 11 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ var (
Address: "",
ProducerPrivKey: PrivateKey.HexString(),
EmptyGenesis: false,
NumCandidates: 101,
GravityChainDB: DB{DbPath: "./poll.db", NumRetries: 10},
Committee: committee.Config{
BeaconChainAPIs: []string{},
Expand Down Expand Up @@ -191,7 +190,6 @@ var (
ValidateExplorer,
ValidateAPI,
ValidateActPool,
ValidateChain,
}

// PrivateKey is a randomly generated producer's key for testing purpose
Expand All @@ -217,7 +215,6 @@ type (
Address string `yaml:"address"`
ProducerPrivKey string `yaml:"producerPrivKey"`
EmptyGenesis bool `yaml:"emptyGenesis"`
NumCandidates uint `yaml:"numCandidates"`
GravityChainDB DB `yaml:"gravityChainDB"`
Committee committee.Config `yaml:"committee"`

Expand Down Expand Up @@ -481,14 +478,6 @@ func (cfg Config) ProducerPrivateKey() keypair.PrivateKey {
return sk
}

// ValidateChain validates the chain configure
func ValidateChain(cfg Config) error {
if cfg.Chain.NumCandidates <= 0 {
return errors.Wrapf(ErrInvalidCfg, "candidate number should be greater than 0")
}
return nil
}

// ValidateDispatcher validates the dispatcher configs
func ValidateDispatcher(cfg Config) error {
if cfg.Dispatcher.EventChanSize <= 0 {
Expand Down
13 changes: 0 additions & 13 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,6 @@ func TestValidateExplorer(t *testing.T) {
)
}

func TestValidateChain(t *testing.T) {
cfg := Default
cfg.Chain.NumCandidates = 0

err := ValidateChain(cfg)
require.Error(t, err)
require.Equal(t, ErrInvalidCfg, errors.Cause(err))
require.True(
t,
strings.Contains(err.Error(), "candidate number should be greater than 0"),
)
}

func TestValidateDispatcher(t *testing.T) {
cfg := Default
cfg.Dispatcher.EventChanSize = 0
Expand Down
Loading

0 comments on commit 071e5c9

Please sign in to comment.