mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
core: deploy new smart-contract in test blocks
Also put smart-contract sources in testdata and add invocation TX with APPCALL and storage.Put.
This commit is contained in:
parent
86cf309085
commit
a2f012e589
5 changed files with 23 additions and 2 deletions
|
@ -214,6 +214,18 @@ func _(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
script = io.NewBufBinWriter()
|
||||
emit.String(script.BinWriter, "testvalue")
|
||||
emit.String(script.BinWriter, "testkey")
|
||||
emit.Int(script.BinWriter, 2)
|
||||
emit.Opcode(script.BinWriter, opcode.PACK)
|
||||
emit.String(script.BinWriter, "Put")
|
||||
emit.AppCall(script.BinWriter, hash.Hash160(avm), false)
|
||||
|
||||
tx3 := transaction.NewInvocationTX(script.Bytes(), util.Fixed8FromFloat(100))
|
||||
b := newBlock(uint32(n+2), newMinerTX(), tx3)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
|
||||
outStream, err := os.Create("../rpc/testdata/testblocks.acc")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -75,13 +75,13 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getcontractstate": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["6d1eeca891ee93de2b7a77eb91c26f3b3c04d6cf"]`,
|
||||
params: `["5ec6b374fd13e53fe60be7901a091695123ea2f0"]`,
|
||||
result: func(e *executor) interface{} { return &GetContractStateResponce{} },
|
||||
check: func(t *testing.T, e *executor, result interface{}) {
|
||||
res, ok := result.(*GetContractStateResponce)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, byte(0), res.Result.Version)
|
||||
assert.Equal(t, util.Uint160{0x6d, 0x1e, 0xec, 0xa8, 0x91, 0xee, 0x93, 0xde, 0x2b, 0x7a, 0x77, 0xeb, 0x91, 0xc2, 0x6f, 0x3b, 0x3c, 0x4, 0xd6, 0xcf}, res.Result.ScriptHash)
|
||||
assert.Equal(t, util.Uint160{0x5e, 0xc6, 0xb3, 0x74, 0xfd, 0x13, 0xe5, 0x3f, 0xe6, 0x0b, 0xe7, 0x90, 0x1a, 0x09, 0x16, 0x95, 0x12, 0x3e, 0xa2, 0xf0}, res.Result.ScriptHash)
|
||||
assert.Equal(t, "0.99", res.Result.CodeVersion)
|
||||
},
|
||||
},
|
||||
|
|
BIN
pkg/rpc/testdata/test_contract.avm
vendored
BIN
pkg/rpc/testdata/test_contract.avm
vendored
Binary file not shown.
9
pkg/rpc/testdata/test_contract.go
vendored
Normal file
9
pkg/rpc/testdata/test_contract.go
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
package testdata
|
||||
|
||||
import "github.com/CityOfZion/neo-go/pkg/interop/storage"
|
||||
|
||||
func Main(operation string, args []interface{}) interface{} {
|
||||
ctx := storage.GetContext()
|
||||
storage.Put(ctx, args[0].([]byte), args[1].([]byte))
|
||||
return true
|
||||
}
|
BIN
pkg/rpc/testdata/testblocks.acc
vendored
BIN
pkg/rpc/testdata/testblocks.acc
vendored
Binary file not shown.
Loading…
Reference in a new issue