2023-02-15 07:05:10 +00:00
|
|
|
package params
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParamsFromAny(t *testing.T) {
|
|
|
|
str := "jajaja"
|
|
|
|
|
2023-04-03 10:34:24 +00:00
|
|
|
ps, err := FromAny([]any{str, smartcontract.Parameter{Type: smartcontract.StringType, Value: str}})
|
2023-02-15 07:05:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, len(ps))
|
|
|
|
|
|
|
|
resStr, err := ps[0].GetString()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, resStr, str)
|
|
|
|
|
|
|
|
resFP, err := ps[1].GetFuncParam()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, resFP.Type, smartcontract.StringType)
|
|
|
|
resStr, err = resFP.Value.GetString()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, resStr, str)
|
|
|
|
|
|
|
|
// Invalid item.
|
2023-04-03 10:34:24 +00:00
|
|
|
_, err = FromAny([]any{smartcontract.Parameter{Type: smartcontract.IntegerType, Value: str}})
|
2023-02-15 07:05:10 +00:00
|
|
|
require.Error(t, err)
|
|
|
|
}
|