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.

43 lines
1.0 KiB

  1. package null
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/tendermint/tendermint/internal/state/indexer"
  7. "github.com/tendermint/tendermint/types"
  8. )
  9. func TestNullEventSink(t *testing.T) {
  10. ctx, cancel := context.WithCancel(context.Background())
  11. defer cancel()
  12. nullIndexer := NewEventSink()
  13. assert.Nil(t, nullIndexer.IndexTxEvents(nil))
  14. assert.Nil(t, nullIndexer.IndexBlockEvents(types.EventDataNewBlockHeader{}))
  15. val1, err1 := nullIndexer.SearchBlockEvents(ctx, nil)
  16. assert.Nil(t, val1)
  17. assert.NoError(t, err1)
  18. val2, err2 := nullIndexer.SearchTxEvents(ctx, nil)
  19. assert.Nil(t, val2)
  20. assert.NoError(t, err2)
  21. val3, err3 := nullIndexer.GetTxByHash(nil)
  22. assert.Nil(t, val3)
  23. assert.NoError(t, err3)
  24. val4, err4 := nullIndexer.HasBlock(0)
  25. assert.False(t, val4)
  26. assert.NoError(t, err4)
  27. }
  28. func TestType(t *testing.T) {
  29. nullIndexer := NewEventSink()
  30. assert.Equal(t, indexer.NULL, nullIndexer.Type())
  31. }
  32. func TestStop(t *testing.T) {
  33. nullIndexer := NewEventSink()
  34. assert.Nil(t, nullIndexer.Stop())
  35. }