smartcontract: always use int64 for integers

It is good when internal representation is unique.
This commit is contained in:
Evgenii Stratonikov 2020-03-18 11:57:33 +03:00
parent 8400f0add2
commit 1e7b47ec05
3 changed files with 7 additions and 7 deletions

View file

@ -181,7 +181,7 @@ func adjustValToType(typ ParamType, val string) (interface{}, error) {
return nil, errors.New("invalid boolean value")
}
case IntegerType:
return strconv.Atoi(val)
return strconv.ParseInt(val, 10, 64)
case Hash160Type:
u, err := address.StringToUint160(val)
if err == nil {

View file

@ -185,15 +185,15 @@ func TestAdjustValToType(t *testing.T) {
}, {
typ: IntegerType,
val: "0",
out: 0,
out: int64(0),
}, {
typ: IntegerType,
val: "42",
out: 42,
out: int64(42),
}, {
typ: IntegerType,
val: "-42",
out: -42,
out: int64(-42),
}, {
typ: IntegerType,
val: "q",

View file

@ -384,13 +384,13 @@ func TestNewParameterFromString(t *testing.T) {
out: Parameter{StringType, "qwerty"},
}, {
in: "42",
out: Parameter{IntegerType, 42},
out: Parameter{IntegerType, int64(42)},
}, {
in: "Hello, 世界",
out: Parameter{StringType, "Hello, 世界"},
}, {
in: `\4\2`,
out: Parameter{IntegerType, 42},
out: Parameter{IntegerType, int64(42)},
}, {
in: `\\4\2`,
out: Parameter{StringType, `\42`},
@ -399,7 +399,7 @@ func TestNewParameterFromString(t *testing.T) {
out: Parameter{StringType, `\42`},
}, {
in: "int:42",
out: Parameter{IntegerType, 42},
out: Parameter{IntegerType, int64(42)},
}, {
in: "true",
out: Parameter{BoolType, true},