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.

38 lines
791 B

  1. package config
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestDefaultConfig(t *testing.T) {
  8. assert := assert.New(t)
  9. // set up some defaults
  10. cfg := DefaultConfig()
  11. assert.NotNil(cfg.P2P)
  12. assert.NotNil(cfg.Mempool)
  13. assert.NotNil(cfg.Consensus)
  14. // check the root dir stuff...
  15. cfg.SetRoot("/foo")
  16. cfg.Genesis = "bar"
  17. cfg.DBPath = "/opt/data"
  18. cfg.Mempool.WalPath = "wal/mem/"
  19. assert.Equal("/foo/bar", cfg.GenesisFile())
  20. assert.Equal("/opt/data", cfg.DBDir())
  21. assert.Equal("/foo/wal/mem", cfg.Mempool.WalDir())
  22. }
  23. func TestConfigValidateBasic(t *testing.T) {
  24. cfg := DefaultConfig()
  25. assert.NoError(t, cfg.ValidateBasic())
  26. // tamper with timeout_propose
  27. cfg.Consensus.TimeoutPropose = -10 * time.Second
  28. assert.Error(t, cfg.ValidateBasic())
  29. }