types: ConsensusParams: add feedback from @ebuchman and @melekes

This commit is contained in:
Emmanuel Odeke
2017-10-20 00:08:39 -06:00
parent bff069f83c
commit f24f03906f
3 changed files with 31 additions and 89 deletions

View File

@ -60,31 +60,3 @@ func TestGenesis(t *testing.T) {
genDoc, err = GenesisDocFromJSON(genDocBytes)
assert.Error(t, err, "expected error for genDoc json with block size of 0")
}
func newConsensusParams(blockSize, partSize int) ConsensusParams {
return ConsensusParams{
BlockSizeParams: BlockSizeParams{MaxBytes: blockSize},
BlockGossipParams: BlockGossipParams{BlockPartSizeBytes: partSize},
}
}
func TestConsensusParams(t *testing.T) {
testCases := []struct {
params ConsensusParams
valid bool
}{
{newConsensusParams(1, 1), true},
{newConsensusParams(1, 0), false},
{newConsensusParams(0, 1), false},
{newConsensusParams(0, 0), false},
}
for _, testCase := range testCases {
if testCase.valid {
assert.NoError(t, testCase.params.Validate(), "expected no error for valid params")
} else {
assert.Error(t, testCase.params.Validate(), "expected error for non valid params")
}
}
}