[#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:
Pavel Karpy 2021-10-22 13:06:08 +03:00 committed by Alex Vanin
parent 3666ae7ad2
commit c167ae26f9
35 changed files with 365 additions and 203 deletions

View file

@ -19,22 +19,22 @@ func TestStartEstimation(t *testing.T) {
stackitem.NewMap(),
}
_, err := ParseStartEstimation(prms)
_, err := ParseStartEstimation(createNotifyEventFromItems(prms))
require.EqualError(t, err, event.WrongNumberOfParameters(1, len(prms)).Error())
})
t.Run("wrong estimation parameter", func(t *testing.T) {
_, err := ParseStartEstimation([]stackitem.Item{
_, err := ParseStartEstimation(createNotifyEventFromItems([]stackitem.Item{
stackitem.NewMap(),
})
}))
require.Error(t, err)
})
t.Run("correct behavior", func(t *testing.T) {
ev, err := ParseStartEstimation([]stackitem.Item{
ev, err := ParseStartEstimation(createNotifyEventFromItems([]stackitem.Item{
epochItem,
})
}))
require.NoError(t, err)
@ -54,22 +54,22 @@ func TestStopEstimation(t *testing.T) {
stackitem.NewMap(),
}
_, err := ParseStopEstimation(prms)
_, err := ParseStopEstimation(createNotifyEventFromItems(prms))
require.EqualError(t, err, event.WrongNumberOfParameters(1, len(prms)).Error())
})
t.Run("wrong estimation parameter", func(t *testing.T) {
_, err := ParseStopEstimation([]stackitem.Item{
_, err := ParseStopEstimation(createNotifyEventFromItems([]stackitem.Item{
stackitem.NewMap(),
})
}))
require.Error(t, err)
})
t.Run("correct behavior", func(t *testing.T) {
ev, err := ParseStopEstimation([]stackitem.Item{
ev, err := ParseStopEstimation(createNotifyEventFromItems([]stackitem.Item{
epochItem,
})
}))
require.NoError(t, err)