improve evm error handling in itests (#10161)
This commit is contained in:
parent
91d0e41444
commit
1ab53051f7
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@ -126,7 +127,11 @@ func (e *EVM) InvokeSolidity(ctx context.Context, sender address.Address, target
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !wait.Receipt.ExitCode.IsSuccess() {
|
||||||
|
result, err := e.StateReplay(ctx, types.EmptyTSK, wait.Message)
|
||||||
|
require.NoError(e.t, err)
|
||||||
|
e.t.Log(result.Error)
|
||||||
|
}
|
||||||
return wait, nil
|
return wait, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +249,9 @@ func (e *EVM) InvokeContractByFuncName(ctx context.Context, fromAddr address.Add
|
|||||||
return nil, wait, err
|
return nil, wait, err
|
||||||
}
|
}
|
||||||
if !wait.Receipt.ExitCode.IsSuccess() {
|
if !wait.Receipt.ExitCode.IsSuccess() {
|
||||||
return nil, wait, fmt.Errorf("contract execution failed - %v", wait.Receipt.ExitCode)
|
result, err := e.StateReplay(ctx, types.EmptyTSK, wait.Message)
|
||||||
|
require.NoError(e.t, err)
|
||||||
|
return nil, wait, errors.New(result.Error)
|
||||||
}
|
}
|
||||||
result, err := cbg.ReadByteArray(bytes.NewBuffer(wait.Receipt.Return), uint64(len(wait.Receipt.Return)))
|
result, err := cbg.ReadByteArray(bytes.NewBuffer(wait.Receipt.Return), uint64(len(wait.Receipt.Return)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user