core: fix getenrollments

Make getvalidators return the same set of keys with C# for mainnet.
This commit is contained in:
Roman Khimov 2021-02-15 23:16:36 +03:00
parent 1ef91fa409
commit 07c91ea22d
2 changed files with 8 additions and 17 deletions

View file

@ -2266,23 +2266,14 @@ func (bc *Blockchain) GetEnrollments() ([]*state.Validator, error) {
for _, validator := range validators {
if validator.Registered {
result = append(result, validator)
continue
}
}
for _, sBValidator := range uniqueSBValidators {
isAdded := false
for _, v := range result {
if v.PublicKey == sBValidator {
isAdded = true
for _, sbValidator := range uniqueSBValidators {
if validator.PublicKey.Equal(sbValidator) {
result = append(result, validator)
break
}
}
if !isAdded {
result = append(result, &state.Validator{
PublicKey: sBValidator,
Registered: false,
Votes: 0,
})
}
}
return result, nil
}

View file

@ -723,12 +723,12 @@ var rpcTestCases = map[string][]rpcTestCase{
},
check: func(t *testing.T, e *executor, validators interface{}) {
var expected []result.Validator
sBValidators, err := e.chain.GetStandByValidators()
enrolls, err := e.chain.GetEnrollments()
require.NoError(t, err)
for _, sbValidator := range sBValidators {
for _, validator := range enrolls {
expected = append(expected, result.Validator{
PublicKey: *sbValidator,
Votes: 0,
PublicKey: *validator.PublicKey,
Votes: validator.Votes,
Active: true,
})
}