(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func TestValidatorValidateBasic(t *testing.T) { |
| 45 | priv := NewMockPV() |
| 46 | pubKey, _ := priv.GetPubKey(context.Background()) |
| 47 | testCases := []struct { |
| 48 | val *Validator |
| 49 | err bool |
| 50 | msg string |
| 51 | }{ |
| 52 | { |
| 53 | val: NewValidator(pubKey, 1), |
| 54 | err: false, |
| 55 | msg: "", |
| 56 | }, |
| 57 | { |
| 58 | val: nil, |
| 59 | err: true, |
| 60 | msg: "nil validator", |
| 61 | }, |
| 62 | { |
| 63 | val: &Validator{ |
| 64 | PubKey: nil, |
| 65 | }, |
| 66 | err: true, |
| 67 | msg: "validator does not have a public key", |
| 68 | }, |
| 69 | { |
| 70 | val: NewValidator(pubKey, -1), |
| 71 | err: true, |
| 72 | msg: "validator has negative voting power", |
| 73 | }, |
| 74 | { |
| 75 | val: &Validator{ |
| 76 | PubKey: pubKey, |
| 77 | Address: nil, |
| 78 | }, |
| 79 | err: true, |
| 80 | msg: "validator address is the wrong size: ", |
| 81 | }, |
| 82 | { |
| 83 | val: &Validator{ |
| 84 | PubKey: pubKey, |
| 85 | Address: []byte{'a'}, |
| 86 | }, |
| 87 | err: true, |
| 88 | msg: "validator address is the wrong size: 61", |
| 89 | }, |
| 90 | } |
| 91 | |
| 92 | for _, tc := range testCases { |
| 93 | err := tc.val.ValidateBasic() |
| 94 | if tc.err { |
| 95 | if assert.Error(t, err) { |
| 96 | assert.Equal(t, tc.msg, err.Error()) |
| 97 | } |
| 98 | } else { |
| 99 | assert.NoError(t, err) |
| 100 | } |
| 101 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…