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.

39 lines
807 B

  1. package core_types
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. "github.com/tendermint/tendermint/p2p"
  6. )
  7. func TestStatusIndexer(t *testing.T) {
  8. assert := assert.New(t)
  9. var status *ResultStatus
  10. assert.False(status.TxIndexEnabled())
  11. status = &ResultStatus{}
  12. assert.False(status.TxIndexEnabled())
  13. status.NodeInfo = &p2p.NodeInfo{}
  14. assert.False(status.TxIndexEnabled())
  15. cases := []struct {
  16. expected bool
  17. other []string
  18. }{
  19. {false, nil},
  20. {false, []string{}},
  21. {false, []string{"a=b"}},
  22. {false, []string{"tx_indexiskv", "some=dood"}},
  23. {true, []string{"tx_index=on", "tx_index=other"}},
  24. {true, []string{"^(*^(", "tx_index=on", "a=n=b=d="}},
  25. }
  26. for _, tc := range cases {
  27. status.NodeInfo.Other = tc.other
  28. assert.Equal(tc.expected, status.TxIndexEnabled())
  29. }
  30. }