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
638 B

  1. package core
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/tendermint/tendermint/types"
  6. )
  7. func TestGetValidatorsWithTimeout(t *testing.T) {
  8. height, vs := getValidatorsWithTimeout(
  9. testValidatorReceiver{},
  10. time.Millisecond,
  11. )
  12. if height != -1 {
  13. t.Errorf("expected negative height")
  14. }
  15. if len(vs) != 0 {
  16. t.Errorf("expected no validators")
  17. }
  18. }
  19. type testValidatorReceiver struct{}
  20. func (tr testValidatorReceiver) GetValidators() (int64, []*types.Validator) {
  21. vs := []*types.Validator{}
  22. for i := 0; i < 3; i++ {
  23. v, _ := types.RandValidator(true, 10)
  24. vs = append(vs, v)
  25. }
  26. time.Sleep(time.Millisecond)
  27. return 10, vs
  28. }