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 { for _, validator := range validators {
if validator.Registered { if validator.Registered {
result = append(result, validator) result = append(result, validator)
continue
} }
} for _, sbValidator := range uniqueSBValidators {
for _, sBValidator := range uniqueSBValidators { if validator.PublicKey.Equal(sbValidator) {
isAdded := false result = append(result, validator)
for _, v := range result {
if v.PublicKey == sBValidator {
isAdded = true
break break
} }
} }
if !isAdded {
result = append(result, &state.Validator{
PublicKey: sBValidator,
Registered: false,
Votes: 0,
})
}
} }
return result, nil return result, nil
} }

View file

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