mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 22:43:47 +00:00
Added a test to prove code change at block level works
This commit is contained in:
parent
d2ea5c22ff
commit
0488cd98e9
2 changed files with 79 additions and 0 deletions
42
eth/tracers/internal/tracetest/firehose/polygon_test.go
Normal file
42
eth/tracers/internal/tracetest/firehose/polygon_test.go
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package firehose_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/big"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPolygon_TracerBlockLevelOnCodeChange(t *testing.T) {
|
||||||
|
tracer, hooks, onClose := newFirehoseTestTracer(t, tracingModelFirehose2_3)
|
||||||
|
defer onClose()
|
||||||
|
|
||||||
|
hooks.OnBlockchainInit(params.BorMainnetChainConfig)
|
||||||
|
hooks.OnBlockStart(tracing.BlockEvent{Block: testBlock()})
|
||||||
|
hooks.OnCodeChange(common.Address{}, common.BytesToHash([]byte{0x01}), []byte{0x01}, common.BytesToHash([]byte{0x02}), []byte{0x02})
|
||||||
|
hooks.OnBlockEnd(nil)
|
||||||
|
|
||||||
|
assertBlockEquals(t, tracer, filepath.Join("testdata", "PolygonBlockLevelCodeChange"), 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBlock() *types.Block {
|
||||||
|
block := types.NewBlock(&types.Header{
|
||||||
|
ParentHash: common.Hash{},
|
||||||
|
Number: big.NewInt(1),
|
||||||
|
Difficulty: big.NewInt(0),
|
||||||
|
Coinbase: common.Address{},
|
||||||
|
Time: 1,
|
||||||
|
GasLimit: 210000,
|
||||||
|
BaseFee: big.NewInt(1000000000),
|
||||||
|
ParentBeaconRoot: ptr(common.Hash{}),
|
||||||
|
}, &types.Body{
|
||||||
|
Transactions: []*types.Transaction{},
|
||||||
|
}, nil, trie.NewStackTrie(nil))
|
||||||
|
|
||||||
|
return block
|
||||||
|
}
|
||||||
37
eth/tracers/internal/tracetest/firehose/testdata/PolygonBlockLevelCodeChange/block.1.golden.json
vendored
Normal file
37
eth/tracers/internal/tracetest/firehose/testdata/PolygonBlockLevelCodeChange/block.1.golden.json
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"codeChanges": [
|
||||||
|
{
|
||||||
|
"address": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"newCode": "Ag==",
|
||||||
|
"newHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI=",
|
||||||
|
"oldCode": "AQ==",
|
||||||
|
"oldHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE=",
|
||||||
|
"ordinal": "1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hash": "WLGMKK1ccyTrarRdy4zscMOz8v4oSRmSquZyaMFyvTA=",
|
||||||
|
"header": {
|
||||||
|
"baseFeePerGas": {
|
||||||
|
"bytes": "O5rKAA=="
|
||||||
|
},
|
||||||
|
"coinbase": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"difficulty": {
|
||||||
|
"bytes": "AA=="
|
||||||
|
},
|
||||||
|
"gasLimit": "210000",
|
||||||
|
"hash": "WLGMKK1ccyTrarRdy4zscMOz8v4oSRmSquZyaMFyvTA=",
|
||||||
|
"logsBloom": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||||
|
"mixHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"number": "1",
|
||||||
|
"parentBeaconRoot": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"parentHash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"receiptRoot": "VugfFxvMVab/g0XmksD4bltI4BuZbK3AAWIvteNjtCE=",
|
||||||
|
"stateRoot": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||||||
|
"timestamp": "1970-01-01T00:00:01Z",
|
||||||
|
"transactionsRoot": "VugfFxvMVab/g0XmksD4bltI4BuZbK3AAWIvteNjtCE=",
|
||||||
|
"uncleHash": "HcxN6N7HXXqrhbVntszUGtMSRRuUinQT8KFC/UDUk0c="
|
||||||
|
},
|
||||||
|
"number": "1",
|
||||||
|
"size": "545",
|
||||||
|
"ver": 3
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue