Skip to content

Commit 3a8dda7

Browse files
zjshen14Yutong Pei
authored and
Yutong Pei
committed
IOTEX-343 Remove numCandidates from config (iotexproject#755)
1 parent 2d2dec3 commit 3a8dda7

File tree

8 files changed

+26
-1022
lines changed

8 files changed

+26
-1022
lines changed

blockchain/blockchain_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ func TestBlockchainInitialCandidate(t *testing.T) {
787787
cfg := config.Default
788788
cfg.Chain.TrieDBPath = testTriePath
789789
cfg.Chain.ChainDBPath = testDBPath
790-
cfg.Chain.NumCandidates = 2
791790

792791
sf, err := factory.NewFactory(cfg, factory.DefaultTrieOption())
793792
require.NoError(err)
@@ -817,7 +816,7 @@ func TestBlockchainInitialCandidate(t *testing.T) {
817816
}()
818817
candidate, err := sf.CandidatesByHeight(0)
819818
require.NoError(err)
820-
require.True(len(candidate) == 2)
819+
require.Equal(24, len(candidate))
821820
}
822821

823822
func TestBlockchain_StateByAddr(t *testing.T) {

config/config.go

-11
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ var (
9797
Address: "",
9898
ProducerPrivKey: PrivateKey.HexString(),
9999
EmptyGenesis: false,
100-
NumCandidates: 101,
101100
GravityChainDB: DB{DbPath: "./poll.db", NumRetries: 10},
102101
Committee: committee.Config{
103102
BeaconChainAPIs: []string{},
@@ -191,7 +190,6 @@ var (
191190
ValidateExplorer,
192191
ValidateAPI,
193192
ValidateActPool,
194-
ValidateChain,
195193
}
196194

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

@@ -481,14 +478,6 @@ func (cfg Config) ProducerPrivateKey() keypair.PrivateKey {
481478
return sk
482479
}
483480

484-
// ValidateChain validates the chain configure
485-
func ValidateChain(cfg Config) error {
486-
if cfg.Chain.NumCandidates <= 0 {
487-
return errors.Wrapf(ErrInvalidCfg, "candidate number should be greater than 0")
488-
}
489-
return nil
490-
}
491-
492481
// ValidateDispatcher validates the dispatcher configs
493482
func ValidateDispatcher(cfg Config) error {
494483
if cfg.Dispatcher.EventChanSize <= 0 {

config/config_test.go

-13
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,6 @@ func TestValidateExplorer(t *testing.T) {
160160
)
161161
}
162162

163-
func TestValidateChain(t *testing.T) {
164-
cfg := Default
165-
cfg.Chain.NumCandidates = 0
166-
167-
err := ValidateChain(cfg)
168-
require.Error(t, err)
169-
require.Equal(t, ErrInvalidCfg, errors.Cause(err))
170-
require.True(
171-
t,
172-
strings.Contains(err.Error(), "candidate number should be greater than 0"),
173-
)
174-
}
175-
176163
func TestValidateDispatcher(t *testing.T) {
177164
cfg := Default
178165
cfg.Dispatcher.EventChanSize = 0

0 commit comments

Comments
 (0)