(t *testing.T)
| 89 | } |
| 90 | |
| 91 | func TestValidatorSetGetValidator(t *testing.T) { |
| 92 | tests := []struct { |
| 93 | name string |
| 94 | detail string |
| 95 | getPublic []byte |
| 96 | vals *ConsensusValidators |
| 97 | expected *ConsensusValidator |
| 98 | error string |
| 99 | }{ |
| 100 | { |
| 101 | name: "not in validator set", |
| 102 | detail: "the validator doesn't exist in the set", |
| 103 | getPublic: newTestPublicKeyBytes(t, 1), |
| 104 | error: "invalid validator index", |
| 105 | }, |
| 106 | { |
| 107 | name: "not in validator set", |
| 108 | detail: "the validator doesn't exist in the set", |
| 109 | getPublic: newTestPublicKeyBytes(t, 1), |
| 110 | vals: &ConsensusValidators{ |
| 111 | ValidatorSet: []*ConsensusValidator{ |
| 112 | { |
| 113 | PublicKey: newTestPublicKeyBytes(t), |
| 114 | VotingPower: 1, |
| 115 | }, |
| 116 | }, |
| 117 | }, |
| 118 | error: "not found in validator set", |
| 119 | }, |
| 120 | { |
| 121 | name: "got vs expected", |
| 122 | detail: "no error, so compare got vs expected", |
| 123 | getPublic: newTestPublicKeyBytes(t), |
| 124 | vals: &ConsensusValidators{ |
| 125 | ValidatorSet: []*ConsensusValidator{ |
| 126 | { |
| 127 | PublicKey: newTestPublicKeyBytes(t), |
| 128 | VotingPower: 1, |
| 129 | }, |
| 130 | }, |
| 131 | }, |
| 132 | expected: &ConsensusValidator{ |
| 133 | PublicKey: newTestPublicKeyBytes(t), |
| 134 | VotingPower: 1, |
| 135 | }, |
| 136 | }, |
| 137 | } |
| 138 | for _, test := range tests { |
| 139 | t.Run(test.name, func(t *testing.T) { |
| 140 | var ( |
| 141 | validatorSet ValidatorSet |
| 142 | err ErrorI |
| 143 | ) |
| 144 | // pre-define a new validator set to test with |
| 145 | if test.vals != nil { |
| 146 | validatorSet, err = NewValidatorSet(test.vals) |
| 147 | require.NoError(t, err) |
| 148 | } |
nothing calls this directly
no test coverage detected