mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
rpc: drop duplicating Invoke* structures
And use smartcontract.Parameter instead of vm.StackItem where appropriate. Closes #689.
This commit is contained in:
parent
56e37ad6ba
commit
4c8d327353
7 changed files with 17 additions and 39 deletions
|
@ -624,7 +624,7 @@ func (s *Server) runScriptInVM(script []byte) *result.Invoke {
|
|||
State: vm.State(),
|
||||
GasConsumed: vm.GasConsumed().String(),
|
||||
Script: hex.EncodeToString(script),
|
||||
Stack: vm.Estack(),
|
||||
Stack: vm.Estack().ToContractParameters(),
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -12,21 +12,11 @@ import (
|
|||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/network"
|
||||
"github.com/CityOfZion/neo-go/pkg/rpc/request"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
// InvokeFunctionResult struct for testing.
|
||||
type InvokeFunctionResult struct {
|
||||
Script string `json:"script"`
|
||||
State string `json:"state"`
|
||||
GasConsumed string `json:"gas_consumed"`
|
||||
Stack []request.FuncParam `json:"stack"`
|
||||
TX string `json:"tx,omitempty"`
|
||||
}
|
||||
|
||||
func initServerWithInMemoryChain(t *testing.T) (*core.Blockchain, http.HandlerFunc) {
|
||||
var nBlocks uint32
|
||||
|
||||
|
|
|
@ -474,9 +474,9 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
params: `["50befd26fdf6e4d957c11e078b24ebce6291456f", [{"type": "String", "value": "qwerty"}]]`,
|
||||
result: func(e *executor) interface{} { return &InvokeFunctionResult{} },
|
||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||
res, ok := inv.(*InvokeFunctionResult)
|
||||
res, ok := inv.(*result.Invoke)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "06717765727479676f459162ceeb248b071ec157d9e4f6fd26fdbe50", res.Script)
|
||||
assert.NotEqual(t, "", res.State)
|
||||
|
@ -513,9 +513,9 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
params: `["50befd26fdf6e4d957c11e078b24ebce6291456f", "test", []]`,
|
||||
result: func(e *executor) interface{} { return &InvokeFunctionResult{} },
|
||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||
res, ok := inv.(*InvokeFunctionResult)
|
||||
res, ok := inv.(*result.Invoke)
|
||||
require.True(t, ok)
|
||||
assert.NotEqual(t, "", res.Script)
|
||||
assert.NotEqual(t, "", res.State)
|
||||
|
@ -547,9 +547,9 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
params: `["51c56b0d48656c6c6f2c20776f726c6421680f4e656f2e52756e74696d652e4c6f67616c7566"]`,
|
||||
result: func(e *executor) interface{} { return &InvokeFunctionResult{} },
|
||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||
res, ok := inv.(*InvokeFunctionResult)
|
||||
res, ok := inv.(*result.Invoke)
|
||||
require.True(t, ok)
|
||||
assert.NotEqual(t, "", res.Script)
|
||||
assert.NotEqual(t, "", res.State)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue