You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
841 B

  1. package types
  2. import (
  3. "testing"
  4. asrt "github.com/stretchr/testify/assert"
  5. )
  6. func TestConsensusParams(t *testing.T) {
  7. assert := asrt.New(t)
  8. params := &ConsensusParams{
  9. BlockSize: &BlockSize{MaxGas: 12345},
  10. BlockGossip: &BlockGossip{BlockPartSizeBytes: 54321},
  11. }
  12. var noParams *ConsensusParams // nil
  13. // no error with nil fields
  14. assert.Nil(noParams.GetBlockSize())
  15. assert.EqualValues(noParams.GetBlockSize().GetMaxGas(), 0)
  16. // get values with real fields
  17. assert.NotNil(params.GetBlockSize())
  18. assert.EqualValues(params.GetBlockSize().GetMaxTxs(), 0)
  19. assert.EqualValues(params.GetBlockSize().GetMaxGas(), 12345)
  20. assert.NotNil(params.GetBlockGossip())
  21. assert.EqualValues(params.GetBlockGossip().GetBlockPartSizeBytes(), 54321)
  22. assert.Nil(params.GetTxSize())
  23. assert.EqualValues(params.GetTxSize().GetMaxBytes(), 0)
  24. }