mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Add test for DoCall ApplyMessage nil return
This commit is contained in:
parent
c1b705392e
commit
ebe1ab2b54
2 changed files with 25 additions and 1 deletions
|
|
@ -1002,6 +1002,9 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
|
|||
// Execute the message.
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||
result, err := core.ApplyMessage(evm, msg, gp)
|
||||
if result == nil && err == nil {
|
||||
return nil, errors.New("EVM ApplyMessage returned nil result without error")
|
||||
}
|
||||
if err := vmError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,3 +157,24 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
|
|||
},
|
||||
}
|
||||
}
|
||||
type mockBackend struct {
|
||||
evmResult *ExecutionResult
|
||||
evmError error
|
||||
}
|
||||
|
||||
func (m *mockBackend) StateAndHeaderByNumberOrHash(_ context.Context, _ rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error) {
|
||||
return &state.StateDB{}, &types.Header{}, nil
|
||||
}
|
||||
|
||||
func (m *mockBackend) Apply(_ *state.StateDB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockBackend) EVM(ctx context.Context, msg Message, state *state.StateDB, header *types.Header, cfg vm.Config) (*ExecutionResult, error) {
|
||||
return m.evmResult, m.evmError
|
||||
}
|
||||
|
||||
func TestDoCall_ApplyMessageReturnsNil(t *testing.T) {
|
||||
backend := &mockBackend{
|
||||
evmResult: nil,
|
||||
evmError:
|
||||
|
|
|
|||
Loading…
Reference in a new issue