rpc: restructure getapplicationlog
response
Move VM-related fields to top-level.
This commit is contained in:
parent
93b0011988
commit
c0e482fe6c
7 changed files with 20 additions and 53 deletions
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||
|
@ -497,14 +496,7 @@ func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, *resp
|
|||
return nil, response.NewRPCError("Unknown transaction", "", nil)
|
||||
}
|
||||
|
||||
tx, _, err := s.chain.GetTransaction(txHash)
|
||||
if err != nil {
|
||||
return nil, response.NewRPCError("Error while getting transaction", "", nil)
|
||||
}
|
||||
|
||||
scriptHash := hash.Hash160(tx.Script)
|
||||
|
||||
return result.NewApplicationLog(appExecResult, scriptHash), nil
|
||||
return result.NewApplicationLog(appExecResult), nil
|
||||
}
|
||||
|
||||
func (s *Server) getNEP5Balances(ps request.Params) (interface{}, *response.Error) {
|
||||
|
@ -1153,7 +1145,7 @@ chloop:
|
|||
resp.Payload[0] = b
|
||||
case execution := <-s.executionCh:
|
||||
resp.Event = response.ExecutionEventID
|
||||
resp.Payload[0] = result.NewApplicationLog(execution, util.Uint160{})
|
||||
resp.Payload[0] = result.NewApplicationLog(execution)
|
||||
case notification := <-s.notificationCh:
|
||||
resp.Event = response.NotificationEventID
|
||||
resp.Payload[0] = result.StateEventToResultNotification(*notification)
|
||||
|
|
|
@ -65,9 +65,8 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
expectedTxHash, err := util.Uint256DecodeStringLE(deploymentTxHash)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||
assert.Equal(t, 1, len(res.Executions))
|
||||
assert.Equal(t, "Application", res.Executions[0].Trigger)
|
||||
assert.Equal(t, "HALT", res.Executions[0].VMState)
|
||||
assert.Equal(t, "Application", res.Trigger)
|
||||
assert.Equal(t, "HALT", res.VMState)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@ func (f *feed) Matches(r *response.Notification) bool {
|
|||
case response.ExecutionEventID:
|
||||
filt := f.filter.(request.ExecutionFilter)
|
||||
applog := r.Payload[0].(result.ApplicationLog)
|
||||
return len(applog.Executions) != 0 && applog.Executions[0].VMState == filt.State
|
||||
return applog.VMState == filt.State
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -185,9 +185,7 @@ func TestFilteredSubscriptions(t *testing.T) {
|
|||
check: func(t *testing.T, resp *response.Notification) {
|
||||
rmap := resp.Payload[0].(map[string]interface{})
|
||||
require.Equal(t, response.ExecutionEventID, resp.Event)
|
||||
execs := rmap["executions"].([]interface{})
|
||||
exec0 := execs[0].(map[string]interface{})
|
||||
st := exec0["vmstate"].(string)
|
||||
st := rmap["vmstate"].(string)
|
||||
require.Equal(t, "HALT", st)
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue