rpc: always marshal FaultException
This commit is contained in:
parent
84629b0760
commit
98b5e2b353
2 changed files with 18 additions and 12 deletions
|
@ -66,7 +66,7 @@ type invokeAux struct {
|
||||||
GasConsumed int64 `json:"gasconsumed,string"`
|
GasConsumed int64 `json:"gasconsumed,string"`
|
||||||
Script []byte `json:"script"`
|
Script []byte `json:"script"`
|
||||||
Stack json.RawMessage `json:"stack"`
|
Stack json.RawMessage `json:"stack"`
|
||||||
FaultException string `json:"exception,omitempty"`
|
FaultException *string `json:"exception"`
|
||||||
Notifications []state.NotificationEvent `json:"notifications"`
|
Notifications []state.NotificationEvent `json:"notifications"`
|
||||||
Transaction []byte `json:"tx,omitempty"`
|
Transaction []byte `json:"tx,omitempty"`
|
||||||
Diagnostics *InvokeDiag `json:"diagnostics,omitempty"`
|
Diagnostics *InvokeDiag `json:"diagnostics,omitempty"`
|
||||||
|
@ -145,16 +145,19 @@ arrloop:
|
||||||
if r.Transaction != nil {
|
if r.Transaction != nil {
|
||||||
txbytes = r.Transaction.Bytes()
|
txbytes = r.Transaction.Bytes()
|
||||||
}
|
}
|
||||||
return json.Marshal(&invokeAux{
|
aux := &invokeAux{
|
||||||
GasConsumed: r.GasConsumed,
|
GasConsumed: r.GasConsumed,
|
||||||
Script: r.Script,
|
Script: r.Script,
|
||||||
State: r.State,
|
State: r.State,
|
||||||
Stack: st,
|
Stack: st,
|
||||||
FaultException: r.FaultException,
|
Notifications: r.Notifications,
|
||||||
Notifications: r.Notifications,
|
Transaction: txbytes,
|
||||||
Transaction: txbytes,
|
Diagnostics: r.Diagnostics,
|
||||||
Diagnostics: r.Diagnostics,
|
}
|
||||||
})
|
if len(r.FaultException) != 0 {
|
||||||
|
aux.FaultException = &r.FaultException
|
||||||
|
}
|
||||||
|
return json.Marshal(aux)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements the json.Unmarshaler.
|
// UnmarshalJSON implements the json.Unmarshaler.
|
||||||
|
@ -207,7 +210,9 @@ func (r *Invoke) UnmarshalJSON(data []byte) error {
|
||||||
r.GasConsumed = aux.GasConsumed
|
r.GasConsumed = aux.GasConsumed
|
||||||
r.Script = aux.Script
|
r.Script = aux.Script
|
||||||
r.State = aux.State
|
r.State = aux.State
|
||||||
r.FaultException = aux.FaultException
|
if aux.FaultException != nil {
|
||||||
|
r.FaultException = *aux.FaultException
|
||||||
|
}
|
||||||
r.Notifications = aux.Notifications
|
r.Notifications = aux.Notifications
|
||||||
r.Transaction = tx
|
r.Transaction = tx
|
||||||
r.Diagnostics = aux.Diagnostics
|
r.Diagnostics = aux.Diagnostics
|
||||||
|
|
|
@ -40,6 +40,7 @@ func TestInvoke_MarshalJSON(t *testing.T) {
|
||||||
{"type":"Integer","value":"1"}
|
{"type":"Integer","value":"1"}
|
||||||
],
|
],
|
||||||
"notifications":[],
|
"notifications":[],
|
||||||
|
"exception": null,
|
||||||
"tx":"` + base64.StdEncoding.EncodeToString(tx.Bytes()) + `"
|
"tx":"` + base64.StdEncoding.EncodeToString(tx.Bytes()) + `"
|
||||||
}`
|
}`
|
||||||
require.JSONEq(t, expected, string(data))
|
require.JSONEq(t, expected, string(data))
|
||||||
|
|
Loading…
Reference in a new issue