[#971] morph/event: Change notification parser's signature
Parsers should have original notification structure to be able to construct internal event structure that contains necessary for unique nonce calculation information. So notification parsers take raw notification structure instead of slice of stack items. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
3666ae7ad2
commit
c167ae26f9
35 changed files with 365 additions and 203 deletions
|
@ -3,6 +3,8 @@ package netmap
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -15,14 +17,14 @@ func TestParseAddPeer(t *testing.T) {
|
|||
stackitem.NewMap(),
|
||||
}
|
||||
|
||||
_, err := ParseAddPeer(prms)
|
||||
_, err := ParseAddPeer(createNotifyEventFromItems(prms))
|
||||
require.EqualError(t, err, event.WrongNumberOfParameters(1, len(prms)).Error())
|
||||
})
|
||||
|
||||
t.Run("wrong first parameter type", func(t *testing.T) {
|
||||
_, err := ParseAddPeer([]stackitem.Item{
|
||||
_, err := ParseAddPeer(createNotifyEventFromItems([]stackitem.Item{
|
||||
stackitem.NewMap(),
|
||||
})
|
||||
}))
|
||||
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
@ -30,9 +32,9 @@ func TestParseAddPeer(t *testing.T) {
|
|||
t.Run("correct behavior", func(t *testing.T) {
|
||||
info := []byte{1, 2, 3}
|
||||
|
||||
ev, err := ParseAddPeer([]stackitem.Item{
|
||||
ev, err := ParseAddPeer(createNotifyEventFromItems([]stackitem.Item{
|
||||
stackitem.NewByteArray(info),
|
||||
})
|
||||
}))
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, AddPeer{
|
||||
|
@ -40,3 +42,11 @@ func TestParseAddPeer(t *testing.T) {
|
|||
}, ev)
|
||||
})
|
||||
}
|
||||
|
||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
||||
return &subscriptions.NotificationEvent{
|
||||
NotificationEvent: state.NotificationEvent{
|
||||
Item: stackitem.NewArray(items),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue