forked from TrueCloudLab/frostfs-node
[#505] morph/client: Support boolean invocation argument
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f2778361c8
commit
fad477df2a
2 changed files with 26 additions and 1 deletions
|
@ -289,6 +289,16 @@ func toStackParameter(value interface{}) (sc.Parameter, error) {
|
|||
}
|
||||
|
||||
return toStackParameter(arr)
|
||||
case bool:
|
||||
// FIXME: there are some problems with BoolType in neo-go,
|
||||
// so we use compatible type
|
||||
result.Type = sc.IntegerType
|
||||
|
||||
if v {
|
||||
result.Value = int64(1)
|
||||
} else {
|
||||
result.Value = int64(0)
|
||||
}
|
||||
default:
|
||||
return result, fmt.Errorf("chain/client: unsupported parameter %v", value)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ func TestToStackParameter(t *testing.T) {
|
|||
items := []struct {
|
||||
value interface{}
|
||||
expType sc.ParamType
|
||||
expVal interface{}
|
||||
}{
|
||||
{
|
||||
value: []byte{1, 2, 3},
|
||||
|
@ -24,6 +25,16 @@ func TestToStackParameter(t *testing.T) {
|
|||
value: "hello world",
|
||||
expType: sc.StringType,
|
||||
},
|
||||
{
|
||||
value: false,
|
||||
expType: sc.IntegerType,
|
||||
expVal: int64(0),
|
||||
},
|
||||
{
|
||||
value: true,
|
||||
expType: sc.IntegerType,
|
||||
expVal: int64(1),
|
||||
},
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
|
@ -31,7 +42,11 @@ func TestToStackParameter(t *testing.T) {
|
|||
res, err := toStackParameter(item.value)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, item.expType, res.Type)
|
||||
if item.expVal != nil {
|
||||
require.Equal(t, item.expVal, res.Value)
|
||||
} else {
|
||||
require.Equal(t, item.value, res.Value)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue