diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index e1d5d3f50..75b2a7a95 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -726,6 +726,28 @@ func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.Public if err != nil { return err } + // we should put it in storage anyway as it affects dumps + err = ic.DAO.PutStorageItem(n.ID, key, si) + if err != nil { + return err + } + if pub != nil { + valKey := makeValidatorKey(pub) + valSi := ic.DAO.GetStorageItem(n.ID, valKey) + if valSi == nil { + return errors.New("unknown validator") + } + cd := new(candidate).FromBytes(valSi) + // we should put it in storage anyway as it affects dumps + err = ic.DAO.PutStorageItem(n.ID, valKey, valSi) + if err != nil { + return err + } + if !cd.Registered { + return errors.New("validator must be registered") + } + } + if (acc.VoteTo == nil) != (pub == nil) { val := &acc.Balance if pub == nil { @@ -765,8 +787,6 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b if ok { return err } - } else if !cd.Registered { - return errors.New("validator must be registered") } n.validators.Store(keys.PublicKeys(nil)) return d.PutStorageItem(n.ID, key, cd.Bytes()) diff --git a/scripts/compare-dumps.go b/scripts/compare-dumps.go index d18897d29..73458c3c0 100644 --- a/scripts/compare-dumps.go +++ b/scripts/compare-dumps.go @@ -15,7 +15,7 @@ import ( "github.com/urfave/cli" ) -var ledgerContractID = -2 +var ledgerContractID = -4 type dump []blockDump diff --git a/scripts/compare-dumps_test.go b/scripts/compare-dumps_test.go new file mode 100644 index 000000000..85a50fc64 --- /dev/null +++ b/scripts/compare-dumps_test.go @@ -0,0 +1,13 @@ +package main + +import ( + "testing" + + "github.com/nspcc-dev/neo-go/pkg/core/native" + "github.com/stretchr/testify/require" +) + +func TestCompatibility(t *testing.T) { + cs := native.NewContracts(false, map[string][]uint32{}) + require.Equal(t, cs.Ledger.ID, int32(ledgerContractID)) +}