From 54d7882acf5a9a95d9bcf525d8dced7fc59f7eb9 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 23 Jul 2020 17:00:06 +0300 Subject: [PATCH] core: compiler contract on-the-fly in helper test Generate proper manifest file too. --- pkg/core/helper_test.go | 11 +++++++---- pkg/rpc/server/testdata/test_contract.avm | Bin 792 -> 0 bytes 2 files changed, 7 insertions(+), 4 deletions(-) delete mode 100755 pkg/rpc/server/testdata/test_contract.avm diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 27397fc1f..a32ec6c8b 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -1,6 +1,7 @@ package core import ( + "bytes" "encoding/hex" "encoding/json" "fmt" @@ -10,6 +11,7 @@ import ( "testing" "time" + "github.com/nspcc-dev/neo-go/pkg/compiler" "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/native" @@ -20,7 +22,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/internal/testserdes" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/smartcontract" - "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" @@ -223,13 +224,15 @@ func TestCreateBasicChain(t *testing.T) { require.NoError(t, err) // Push some contract into the chain. - avm, err := ioutil.ReadFile(prefix + "test_contract.avm") + c, err := ioutil.ReadFile(prefix + "test_contract.go") + require.NoError(t, err) + avm, di, err := compiler.CompileWithDebugInfo(bytes.NewReader(c)) require.NoError(t, err) t.Logf("contractHash: %s", hash.Hash160(avm).StringLE()) script := io.NewBufBinWriter() - m := manifest.NewManifest(hash.Hash160(avm)) - m.Features = smartcontract.HasStorage + m, err := di.ConvertToManifest(smartcontract.HasStorage) + require.NoError(t, err) bs, err := m.MarshalJSON() require.NoError(t, err) emit.Bytes(script.BinWriter, bs) diff --git a/pkg/rpc/server/testdata/test_contract.avm b/pkg/rpc/server/testdata/test_contract.avm deleted file mode 100755 index dbb93433899a0a48093d0625d5a48d3720a8c5c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 792 zcmZ`%F>ljA7*zqNGLWLM(9C3{8%7R_VLW+cl8bK$7E{+XO&-VrUTqn%@0t9$K zf)ydL(VZEIuvYR8`~pVAotrd`D9cHA?|bjwd-@($4!af9@PP4{c)a5gN~g1a`%B+> zy#d6W_RwZO$$+qPbnK$Vfm&v9EmqUu39q_*|EM6M*WXb5zn zhBgl#?AzAk64Hi*66X2$gB)k)2A`Gw;&Jb^yY=-()isoz&)5_&+78(dB>=3JX0{4Ou8w@SeDw)te!w`166AS)*L8 mtO*Dj(ELXcDaCFHtchAOS8Le}O#GPe5Lj8xZEH)QuKgDli}cR`