compiler: remove offset comparison from debug test

We shouldn't test for them anyway plus the error is more
specific now.
This commit is contained in:
Evgeniy Stratonikov 2021-05-12 15:02:40 +03:00
parent fec214055f
commit e8ba386e58

View file

@ -158,14 +158,12 @@ func _deploy(data interface{}, isUpdate bool) {}
t.Run("convert to Manifest", func(t *testing.T) { t.Run("convert to Manifest", func(t *testing.T) {
actual, err := d.ConvertToManifest(&Options{Name: "MyCTR", SafeMethods: []string{"methodInt", "methodString"}}) actual, err := d.ConvertToManifest(&Options{Name: "MyCTR", SafeMethods: []string{"methodInt", "methodString"}})
require.NoError(t, err) require.NoError(t, err)
// note: offsets are hard to predict, so we just take them from the output
expected := &manifest.Manifest{ expected := &manifest.Manifest{
Name: "MyCTR", Name: "MyCTR",
ABI: manifest.ABI{ ABI: manifest.ABI{
Methods: []manifest.Method{ Methods: []manifest.Method{
{ {
Name: "_deploy", Name: "_deploy",
Offset: 0,
Parameters: []manifest.Parameter{ Parameters: []manifest.Parameter{
manifest.NewParameter("data", smartcontract.AnyType), manifest.NewParameter("data", smartcontract.AnyType),
manifest.NewParameter("isUpdate", smartcontract.BoolType), manifest.NewParameter("isUpdate", smartcontract.BoolType),
@ -174,7 +172,6 @@ func _deploy(data interface{}, isUpdate bool) {}
}, },
{ {
Name: "main", Name: "main",
Offset: 4,
Parameters: []manifest.Parameter{ Parameters: []manifest.Parameter{
manifest.NewParameter("op", smartcontract.StringType), manifest.NewParameter("op", smartcontract.StringType),
}, },
@ -182,7 +179,6 @@ func _deploy(data interface{}, isUpdate bool) {}
}, },
{ {
Name: "methodInt", Name: "methodInt",
Offset: 70,
Parameters: []manifest.Parameter{ Parameters: []manifest.Parameter{
{ {
Name: "a", Name: "a",
@ -194,32 +190,27 @@ func _deploy(data interface{}, isUpdate bool) {}
}, },
{ {
Name: "methodString", Name: "methodString",
Offset: 101,
Parameters: []manifest.Parameter{}, Parameters: []manifest.Parameter{},
ReturnType: smartcontract.StringType, ReturnType: smartcontract.StringType,
Safe: true, Safe: true,
}, },
{ {
Name: "methodByteArray", Name: "methodByteArray",
Offset: 107,
Parameters: []manifest.Parameter{}, Parameters: []manifest.Parameter{},
ReturnType: smartcontract.ByteArrayType, ReturnType: smartcontract.ByteArrayType,
}, },
{ {
Name: "methodArray", Name: "methodArray",
Offset: 112,
Parameters: []manifest.Parameter{}, Parameters: []manifest.Parameter{},
ReturnType: smartcontract.ArrayType, ReturnType: smartcontract.ArrayType,
}, },
{ {
Name: "methodStruct", Name: "methodStruct",
Offset: 117,
Parameters: []manifest.Parameter{}, Parameters: []manifest.Parameter{},
ReturnType: smartcontract.ArrayType, ReturnType: smartcontract.ArrayType,
}, },
{ {
Name: "methodConcat", Name: "methodConcat",
Offset: 92,
Parameters: []manifest.Parameter{ Parameters: []manifest.Parameter{
{ {
Name: "a", Name: "a",
@ -238,7 +229,6 @@ func _deploy(data interface{}, isUpdate bool) {}
}, },
{ {
Name: "methodParams", Name: "methodParams",
Offset: 129,
Parameters: []manifest.Parameter{ Parameters: []manifest.Parameter{
manifest.NewParameter("addr", smartcontract.Hash160Type), manifest.NewParameter("addr", smartcontract.Hash160Type),
manifest.NewParameter("h", smartcontract.Hash256Type), manifest.NewParameter("h", smartcontract.Hash256Type),
@ -267,7 +257,15 @@ func _deploy(data interface{}, isUpdate bool) {}
}, },
Extra: json.RawMessage("null"), Extra: json.RawMessage("null"),
} }
require.ElementsMatch(t, expected.ABI.Methods, actual.ABI.Methods) require.Equal(t, len(expected.ABI.Methods), len(actual.ABI.Methods))
for _, exp := range expected.ABI.Methods {
md := actual.ABI.GetMethod(exp.Name, len(exp.Parameters))
require.NotNil(t, md)
require.Equal(t, exp.Name, md.Name)
require.Equal(t, exp.Parameters, md.Parameters)
require.Equal(t, exp.ReturnType, md.ReturnType)
require.Equal(t, exp.Safe, md.Safe)
}
require.Equal(t, expected.ABI.Events, actual.ABI.Events) require.Equal(t, expected.ABI.Events, actual.ABI.Events)
require.Equal(t, expected.Groups, actual.Groups) require.Equal(t, expected.Groups, actual.Groups)
require.Equal(t, expected.Permissions, actual.Permissions) require.Equal(t, expected.Permissions, actual.Permissions)