[#298] ir: Fix parser of UpdateState notification event of Netmap contract

The order of event stack items is {state, key}.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-11 14:52:48 +03:00 committed by Alex Vanin
parent 07a6e2cc43
commit d26716e792
2 changed files with 3 additions and 3 deletions

View file

@ -39,7 +39,7 @@ func ParseUpdatePeer(prms []stackitem.Item) (event.Event, error) {
} }
// parse public key // parse public key
key, err := client.BytesFromStackItem(prms[0]) key, err := client.BytesFromStackItem(prms[1])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get public key") return nil, errors.Wrap(err, "could not get public key")
} }
@ -50,7 +50,7 @@ func ParseUpdatePeer(prms []stackitem.Item) (event.Event, error) {
} }
// parse node status // parse node status
st, err := client.IntFromStackItem(prms[1]) st, err := client.IntFromStackItem(prms[0])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not get node status") return nil, errors.Wrap(err, "could not get node status")
} }

View file

@ -48,8 +48,8 @@ func TestParseUpdatePeer(t *testing.T) {
t.Run("correct behavior", func(t *testing.T) { t.Run("correct behavior", func(t *testing.T) {
ev, err := ParseUpdatePeer([]stackitem.Item{ ev, err := ParseUpdatePeer([]stackitem.Item{
stackitem.NewByteArray(crypto.MarshalPublicKey(publicKey)),
stackitem.NewBigInteger(new(big.Int).SetInt64(int64(state.ToV2()))), stackitem.NewBigInteger(new(big.Int).SetInt64(int64(state.ToV2()))),
stackitem.NewByteArray(crypto.MarshalPublicKey(publicKey)),
}) })
require.NoError(t, err) require.NoError(t, err)