2020-07-10 14:17:51 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
2020-07-24 13:54:03 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
2020-07-10 14:17:51 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseNewEpoch(t *testing.T) {
|
|
|
|
t.Run("wrong number of parameters", func(t *testing.T) {
|
|
|
|
prms := []smartcontract.Parameter{
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := ParseNewEpoch(prms)
|
|
|
|
require.EqualError(t, err, event.WrongNumberOfParameters(1, len(prms)).Error())
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("wrong first parameter type", func(t *testing.T) {
|
|
|
|
_, err := ParseNewEpoch([]smartcontract.Parameter{
|
|
|
|
{
|
|
|
|
Type: smartcontract.ByteArrayType,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("correct behavior", func(t *testing.T) {
|
|
|
|
epochNum := uint64(100)
|
|
|
|
|
|
|
|
ev, err := ParseNewEpoch([]smartcontract.Parameter{
|
|
|
|
{
|
|
|
|
Type: smartcontract.IntegerType,
|
|
|
|
Value: int64(epochNum),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, NewEpoch{
|
|
|
|
num: epochNum,
|
|
|
|
}, ev)
|
|
|
|
})
|
|
|
|
}
|