(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestValidatorSetGetValidatorAndIndex(t *testing.T) { |
| 165 | tests := []struct { |
| 166 | name string |
| 167 | detail string |
| 168 | getPublic []byte |
| 169 | vals *ConsensusValidators |
| 170 | expected *ConsensusValidator |
| 171 | expectedIdx int |
| 172 | error string |
| 173 | }{ |
| 174 | { |
| 175 | name: "not in validator set", |
| 176 | detail: "the validator doesn't exist in the set", |
| 177 | getPublic: newTestPublicKeyBytes(t, 1), |
| 178 | error: "invalid validator index", |
| 179 | }, |
| 180 | { |
| 181 | name: "not in validator set", |
| 182 | detail: "the validator doesn't exist in the set", |
| 183 | getPublic: newTestPublicKeyBytes(t, 1), |
| 184 | vals: &ConsensusValidators{ |
| 185 | ValidatorSet: []*ConsensusValidator{ |
| 186 | { |
| 187 | PublicKey: newTestPublicKeyBytes(t), |
| 188 | VotingPower: 1, |
| 189 | }, |
| 190 | }, |
| 191 | }, |
| 192 | error: "not found in validator set", |
| 193 | }, |
| 194 | { |
| 195 | name: "got vs expected", |
| 196 | detail: "no error, so compare got vs expected", |
| 197 | getPublic: newTestPublicKeyBytes(t, 1), |
| 198 | vals: &ConsensusValidators{ |
| 199 | ValidatorSet: []*ConsensusValidator{ |
| 200 | { |
| 201 | PublicKey: newTestPublicKeyBytes(t), |
| 202 | VotingPower: 1, |
| 203 | }, |
| 204 | { |
| 205 | PublicKey: newTestPublicKeyBytes(t, 1), |
| 206 | VotingPower: 1, |
| 207 | }, |
| 208 | }, |
| 209 | }, |
| 210 | expectedIdx: 1, |
| 211 | expected: &ConsensusValidator{ |
| 212 | PublicKey: newTestPublicKeyBytes(t, 1), |
| 213 | VotingPower: 1, |
| 214 | }, |
| 215 | }, |
| 216 | } |
| 217 | for _, test := range tests { |
| 218 | t.Run(test.name, func(t *testing.T) { |
| 219 | var ( |
| 220 | validatorSet ValidatorSet |
| 221 | err ErrorI |
nothing calls this directly
no test coverage detected