mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Added the fixed test case and also uses make header function now
This commit is contained in:
parent
78c435f590
commit
829774feda
3 changed files with 5 additions and 27 deletions
|
|
@ -955,9 +955,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
|
|
||||||
hdr := *block.Header()
|
hdr := *block.Header()
|
||||||
if config != nil {
|
if config != nil {
|
||||||
if err := config.BlockOverrides.ApplyHeader(&hdr); err != nil {
|
hdr = *config.BlockOverrides.MakeHeader(block.Header())
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vmctx := core.NewEVMBlockContext(&hdr, api.chainContext(ctx), nil)
|
vmctx := core.NewEVMBlockContext(&hdr, api.chainContext(ctx), nil)
|
||||||
|
|
|
||||||
|
|
@ -689,6 +689,9 @@ func TestTracingWithOverrides(t *testing.T) {
|
||||||
Failed bool
|
Failed bool
|
||||||
ReturnValue string
|
ReturnValue string
|
||||||
}
|
}
|
||||||
|
parentHashHex := backend.chain.GetHeaderByNumber(uint64(genBlocks - 1)).Hash().Hex()[2:]
|
||||||
|
return96 := fmt.Sprintf("0x%064s%s%064s", "", parentHashHex, "")
|
||||||
|
|
||||||
var testSuite = []struct {
|
var testSuite = []struct {
|
||||||
blockNumber rpc.BlockNumber
|
blockNumber rpc.BlockNumber
|
||||||
call ethapi.TransactionArgs
|
call ethapi.TransactionArgs
|
||||||
|
|
@ -786,7 +789,7 @@ func TestTracingWithOverrides(t *testing.T) {
|
||||||
config: &TraceCallConfig{
|
config: &TraceCallConfig{
|
||||||
BlockOverrides: &override.BlockOverrides{Number: (*hexutil.Big)(big.NewInt(0x1337))},
|
BlockOverrides: &override.BlockOverrides{Number: (*hexutil.Big)(big.NewInt(0x1337))},
|
||||||
},
|
},
|
||||||
want: `{"gas":72666,"failed":false,"returnValue":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}`,
|
want: fmt.Sprintf(`{"gas":72666,"failed":false,"returnValue":"%s"}`, return96),
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
pragma solidity =0.8.12;
|
pragma solidity =0.8.12;
|
||||||
|
|
|
||||||
|
|
@ -171,29 +171,6 @@ func (o *BlockOverrides) Apply(blockCtx *vm.BlockContext) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *BlockOverrides) ApplyHeader(h *types.Header) error {
|
|
||||||
if o == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if o.Number != nil {
|
|
||||||
h.Number = o.Number.ToInt()
|
|
||||||
}
|
|
||||||
if o.Time != nil {
|
|
||||||
h.Time = uint64(*o.Time)
|
|
||||||
}
|
|
||||||
if o.GasLimit != nil {
|
|
||||||
h.GasLimit = uint64(*o.GasLimit)
|
|
||||||
}
|
|
||||||
if o.Difficulty != nil {
|
|
||||||
h.Difficulty = o.Difficulty.ToInt()
|
|
||||||
}
|
|
||||||
if o.BaseFeePerGas != nil {
|
|
||||||
h.BaseFee = o.BaseFeePerGas.ToInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MakeHeader returns a new header object with the overridden
|
// MakeHeader returns a new header object with the overridden
|
||||||
// fields.
|
// fields.
|
||||||
// Note: MakeHeader ignores BlobBaseFee if set. That's because
|
// Note: MakeHeader ignores BlobBaseFee if set. That's because
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue