MCPcopy
hub / github.com/canopy-network/canopy / TestValidatorSetGetValidatorAndIndex

Function TestValidatorSetGetValidatorAndIndex

lib/consensus_test.go:164–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

162}
163
164func 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

Callers

nothing calls this directly

Calls 5

NewValidatorSetFunction · 0.85
RunMethod · 0.80
GetValidatorAndIdxMethod · 0.80
EqualMethod · 0.80
newTestPublicKeyBytesFunction · 0.70

Tested by

no test coverage detected