Browse Source

add a test for ConsensusParams#Update

Refs #693
pull/1936/head
Anton Kaliaev 6 years ago
parent
commit
5a4459935b
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 57 additions and 0 deletions
  1. +57
    -0
      types/params_test.go

+ 57
- 0
types/params_test.go View File

@ -6,6 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
abci "github.com/tendermint/tendermint/abci/types"
)
func newConsensusParams(blockSize, partSize int) ConsensusParams {
@ -86,3 +87,59 @@ func TestConsensusParamsHash(t *testing.T) {
assert.NotEqual(t, hashes[i], hashes[i+1])
}
}
func TestConsensusParamsUpdate(t *testing.T) {
testCases := []struct {
params ConsensusParams
updates *abci.ConsensusParams
updatedParams ConsensusParams
}{
// empty updates
{
makeParams(1, 2, 3, 4, 5, 6),
&abci.ConsensusParams{},
makeParams(1, 2, 3, 4, 5, 6),
},
// negative BlockPartSizeBytes
{
makeParams(1, 2, 3, 4, 5, 6),
&abci.ConsensusParams{
BlockSize: &abci.BlockSize{
MaxBytes: -100,
MaxTxs: -200,
MaxGas: -300,
},
TxSize: &abci.TxSize{
MaxBytes: -400,
MaxGas: -500,
},
BlockGossip: &abci.BlockGossip{
BlockPartSizeBytes: -600,
},
},
makeParams(1, 2, 3, 4, 5, 6),
},
// fine updates
{
makeParams(1, 2, 3, 4, 5, 6),
&abci.ConsensusParams{
BlockSize: &abci.BlockSize{
MaxBytes: 100,
MaxTxs: 200,
MaxGas: 300,
},
TxSize: &abci.TxSize{
MaxBytes: 400,
MaxGas: 500,
},
BlockGossip: &abci.BlockGossip{
BlockPartSizeBytes: 600,
},
},
makeParams(100, 200, 300, 400, 500, 600),
},
}
for _, tc := range testCases {
assert.Equal(t, tc.updatedParams, tc.params.Update(tc.updates))
}
}

Loading…
Cancel
Save