From dce456f77ff2c10a754261778e9d44f9919bc8f5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 27 Aug 2020 18:05:26 +0300 Subject: [PATCH] native: fix a bug in `GetCommitteeMembers` Return standby committee instead of validators. --- pkg/core/native/native_neo.go | 4 ++-- pkg/core/native_neo_test.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 5eb99da93..c8486d005 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -485,13 +485,13 @@ func (n *NEO) GetCommitteeMembers(bc blockchainer.Blockchainer, d dao.DAO) (keys votersCount.Mul(votersCount, big.NewInt(effectiveVoterTurnout)) voterTurnout := votersCount.Div(votersCount, n.getTotalSupply(d)) if voterTurnout.Sign() != 1 { - return bc.GetStandByValidators(), nil + return bc.GetStandByCommittee(), nil } cs, err := n.getCandidates(d) if err != nil { return nil, err } - sbVals := bc.GetStandByValidators() + sbVals := bc.GetStandByCommittee() count := len(sbVals) if len(cs) < count { return sbVals, nil diff --git a/pkg/core/native_neo_test.go b/pkg/core/native_neo_test.go index 9cce25773..2fc60d29b 100644 --- a/pkg/core/native_neo_test.go +++ b/pkg/core/native_neo_test.go @@ -83,6 +83,11 @@ func TestNEO_Vote(t *testing.T) { ic.VM.Load(priv.PublicKey().GetVerificationScript()) require.NoError(t, neo.VoteInternal(ic, h, candidates[0])) + for i := testchain.ValidatorsCount; i < testchain.CommitteeSize(); i++ { + priv := testchain.PrivateKey(i) + require.NoError(t, neo.RegisterCandidateInternal(ic, priv.PublicKey())) + } + pubs, err = neo.GetValidatorsInternal(bc, ic.DAO) require.NoError(t, err) sortedCandidates := candidates.Copy()