compiler: provide .go
filename to Compile
First argument contains filename, thus we use '.go' suffix to distinguish between directories and files. Contract name should be provided in options. Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
8af9c870b1
commit
e7a0ecb349
10 changed files with 35 additions and 28 deletions
|
@ -93,7 +93,7 @@ func compileFile(src string) error {
|
|||
|
||||
func TestOnPayableChecks(t *testing.T) {
|
||||
compileAndCheck := func(t *testing.T, src string) error {
|
||||
_, di, err := compiler.CompileWithOptions("payable", strings.NewReader(src), nil)
|
||||
_, di, err := compiler.CompileWithOptions("payable.go", strings.NewReader(src), nil)
|
||||
require.NoError(t, err)
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{})
|
||||
return err
|
||||
|
@ -129,7 +129,8 @@ func TestSafeMethodWarnings(t *testing.T) {
|
|||
src := `package payable
|
||||
func Main() int { return 1 }`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src), nil)
|
||||
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src),
|
||||
&compiler.Options{Name: "eventTest"})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{SafeMethods: []string{"main"}})
|
||||
|
@ -144,7 +145,7 @@ func TestEventWarnings(t *testing.T) {
|
|||
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
func Main() { runtime.Notify("Event", 1) }`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src), nil)
|
||||
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("event it missing from config", func(t *testing.T) {
|
||||
|
@ -188,7 +189,7 @@ func TestEventWarnings(t *testing.T) {
|
|||
return notify.Value
|
||||
}`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src), nil)
|
||||
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src), &compiler.Options{Name: "eventTest"})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{NoEventsCheck: true})
|
||||
|
@ -202,7 +203,8 @@ func TestEventWarnings(t *testing.T) {
|
|||
return 42
|
||||
}`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src), nil)
|
||||
_, di, err := compiler.CompileWithOptions("eventTest.go",
|
||||
strings.NewReader(src), &compiler.Options{Name: "eventTest"})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{})
|
||||
|
@ -224,12 +226,12 @@ func TestNotifyInVerify(t *testing.T) {
|
|||
for _, name := range []string{"Notify", "Log"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
src := fmt.Sprintf(srcTmpl, name)
|
||||
_, _, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src),
|
||||
_, _, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src),
|
||||
&compiler.Options{ContractEvents: []manifest.Event{{Name: "Event"}}})
|
||||
require.Error(t, err)
|
||||
|
||||
t.Run("suppress", func(t *testing.T) {
|
||||
_, _, err := compiler.CompileWithOptions("eventTest", strings.NewReader(src),
|
||||
_, _, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src),
|
||||
&compiler.Options{NoEventsCheck: true})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
@ -258,7 +260,7 @@ func TestInvokedContractsPermissons(t *testing.T) {
|
|||
return 0
|
||||
}`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("permissionTest", strings.NewReader(src), &compiler.Options{})
|
||||
_, di, err := compiler.CompileWithOptions("permissionTest.go", strings.NewReader(src), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
var nh util.Uint160
|
||||
|
@ -302,7 +304,7 @@ func TestInvokedContractsPermissons(t *testing.T) {
|
|||
contract.Call(runh.RuntimeHash(), "method4", contract.All)
|
||||
}`, hashStr)
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("permissionTest", strings.NewReader(src), &compiler.Options{})
|
||||
_, di, err := compiler.CompileWithOptions("permissionTest.go", strings.NewReader(src), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
var h util.Uint160
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue