mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 13:47:19 +00:00
Merge pull request #2206 from nspcc-dev/compiler-safe-methods
compiler: check that safe methods exist
This commit is contained in:
commit
fb31a81fd2
2 changed files with 19 additions and 0 deletions
|
@ -270,6 +270,11 @@ func CreateManifest(di *DebugInfo, o *Options) (*manifest.Manifest, error) {
|
|||
if err != nil {
|
||||
return m, fmt.Errorf("failed to convert debug info to manifest: %w", err)
|
||||
}
|
||||
for _, name := range o.SafeMethods {
|
||||
if m.ABI.GetMethod(name, -1) == nil {
|
||||
return m, fmt.Errorf("method %s is marked as safe but missing from manifest", name)
|
||||
}
|
||||
}
|
||||
if !o.NoStandardCheck {
|
||||
if err := standard.CheckABI(m, o.ContractSupportedStandards...); err != nil {
|
||||
return m, err
|
||||
|
|
|
@ -125,6 +125,20 @@ func TestOnPayableChecks(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestSafeMethodWarnings(t *testing.T) {
|
||||
src := `package payable
|
||||
func Main() int { return 1 }`
|
||||
|
||||
_, di, err := compiler.CompileWithDebugInfo("eventTest", strings.NewReader(src))
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{SafeMethods: []string{"main"}})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{SafeMethods: []string{"main", "mississippi"}})
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestEventWarnings(t *testing.T) {
|
||||
src := `package payable
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
|
|
Loading…
Reference in a new issue