From b997eeb051aa095d293f16bbe1b90eadd8c2d0d2 Mon Sep 17 00:00:00 2001 From: Anthony De Meulemeester Date: Wed, 22 Aug 2018 19:07:36 +0200 Subject: [PATCH] fixed token example and fixed compiler test with multiple dirs (CityOfZion/neo-storm#20) Imported from CityOfZion/neo-storm (2d0814a04c34f320dee41674066ccd766a7a8ea1). --- examples/token/{vendor => }/nep5/nep5.go | 0 examples/token/token.go | 2 +- examples/token/{vendor => }/token/token.go | 0 pkg/vm/compiler/compiler_test.go | 15 +++++++++++---- 4 files changed, 12 insertions(+), 5 deletions(-) rename examples/token/{vendor => }/nep5/nep5.go (100%) rename examples/token/{vendor => }/token/token.go (100%) diff --git a/examples/token/vendor/nep5/nep5.go b/examples/token/nep5/nep5.go similarity index 100% rename from examples/token/vendor/nep5/nep5.go rename to examples/token/nep5/nep5.go diff --git a/examples/token/token.go b/examples/token/token.go index 73b3ffba7..834d0ffbd 100644 --- a/examples/token/token.go +++ b/examples/token/token.go @@ -1,7 +1,7 @@ package token_contract import ( - "nep5" + "github.com/CityOfZion/neo-storm/examples/token/nep5" "github.com/CityOfZion/neo-storm/interop/storage" "github.com/CityOfZion/neo-storm/interop/util" diff --git a/examples/token/vendor/token/token.go b/examples/token/token/token.go similarity index 100% rename from examples/token/vendor/token/token.go rename to examples/token/token/token.go diff --git a/pkg/vm/compiler/compiler_test.go b/pkg/vm/compiler/compiler_test.go index a42bd418d..1ab46d1ae 100644 --- a/pkg/vm/compiler/compiler_test.go +++ b/pkg/vm/compiler/compiler_test.go @@ -22,13 +22,11 @@ func TestExamplesFolder(t *testing.T) { if err != nil { t.Fatal(err) } - if len(infos) > 1 { - t.Fatal("detected smart contract folder with more than 1 contract file") - } if len(infos) == 0 { t.Fatal("detected smart contract folder with no contract in it") } - filename := infos[0].Name() + + filename := filterFilename(infos) targetPath := path.Join(examplePath, info.Name(), filename) if err := compileFile(targetPath); err != nil { t.Fatal(err) @@ -36,6 +34,15 @@ func TestExamplesFolder(t *testing.T) { } } +func filterFilename(infos []os.FileInfo) string { + for _, info := range infos { + if !info.IsDir() { + return info.Name() + } + } + return "" +} + func compileFile(src string) error { o := compiler.Options{ Outfile: "tmp/contract.avm",