MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestValidatorValidateBasic

Function TestValidatorValidateBasic

types/validator_test.go:44–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func 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 }

Callers

nothing calls this directly

Calls 6

GetPubKeyMethod · 0.95
NewMockPVFunction · 0.85
NewValidatorFunction · 0.85
ValidateBasicMethod · 0.65
ErrorMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…