conesnsu: follow up to removing some consensus params (#2427)

* follow up to removing some consensus params Refs #2382
* change args type to int64 in state#makeParams
* make valsCount and evidenceCount ints again
* MaxEvidenceBytesPerBlock: include magic number in godoc
* [spec] creating a proposal
* test state#TxFilter
* panic if MaxDataBytes is less than 0
* fixes after review
* use amino#UvarintSize to calculate overhead
0c74291f3b/encoder.go (L85-L90)
* avoid cyclic imports
* you can do better Go, come on
* remove testdouble package
This commit is contained in:
Anton Kaliaev
2018-09-21 13:00:36 +04:00
committed by Alexander Simmerl
parent 7b727bf3d0
commit 8d50bb9dad
27 changed files with 347 additions and 175 deletions

View File

@@ -266,7 +266,7 @@ func TestMaxHeaderBytes(t *testing.T) {
bz, err := cdc.MarshalBinary(h)
require.NoError(t, err)
assert.Equal(t, MaxHeaderBytes, len(bz))
assert.EqualValues(t, MaxHeaderBytes, len(bz))
}
func randCommit() *Commit {
@@ -279,3 +279,60 @@ func randCommit() *Commit {
}
return commit
}
func TestBlockMaxDataBytes(t *testing.T) {
testCases := []struct {
maxBytes int64
valsCount int
evidenceCount int
panics bool
result int64
}{
0: {-10, 1, 0, true, 0},
1: {10, 1, 0, true, 0},
2: {721, 1, 0, true, 0},
3: {722, 1, 0, false, 0},
4: {723, 1, 0, false, 1},
}
for i, tc := range testCases {
if tc.panics {
assert.Panics(t, func() {
MaxDataBytes(tc.maxBytes, tc.valsCount, tc.evidenceCount)
}, "#%v", i)
} else {
assert.Equal(t,
tc.result,
MaxDataBytes(tc.maxBytes, tc.valsCount, tc.evidenceCount),
"#%v", i)
}
}
}
func TestBlockMaxDataBytesUnknownEvidence(t *testing.T) {
testCases := []struct {
maxBytes int64
valsCount int
panics bool
result int64
}{
0: {-10, 1, true, 0},
1: {10, 1, true, 0},
2: {801, 1, true, 0},
3: {802, 1, false, 0},
4: {803, 1, false, 1},
}
for i, tc := range testCases {
if tc.panics {
assert.Panics(t, func() {
MaxDataBytesUnknownEvidence(tc.maxBytes, tc.valsCount)
}, "#%v", i)
} else {
assert.Equal(t,
tc.result,
MaxDataBytesUnknownEvidence(tc.maxBytes, tc.valsCount),
"#%v", i)
}
}
}