From 07c91ea22d10042be0348057bd1d52b769161b8e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 15 Feb 2021 23:16:36 +0300 Subject: [PATCH] core: fix getenrollments Make getvalidators return the same set of keys with C# for mainnet. --- pkg/core/blockchain.go | 17 ++++------------- pkg/rpc/server/server_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 8bb1b0b9a..1e56785cc 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -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 } diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index 698dbfe23..4902396ba 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -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, }) }