Skip to content

Commit 60827dc

Browse files
holimanfjl
authored andcommitted
tests: update tests, implement no-pow blocks (#17902)
This commit updates our tests with the latest and greatest from ethereum/tests. It also contains implementation of NoProof for blockchain tests.
1 parent 2e98631 commit 60827dc

5 files changed

Lines changed: 27 additions & 30 deletions

File tree

‎tests/block_test.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func TestBlockchain(t *testing.T) {
3030
bt.skipLoad(`^bcForgedTest/bcForkUncle\.json`)
3131
bt.skipLoad(`^bcMultiChainTest/(ChainAtoChainB_blockorder|CallContractFromNotBestBlock)`)
3232
bt.skipLoad(`^bcTotalDifficultyTest/(lotsOfLeafs|lotsOfBranches|sideChainWithMoreTransactions)`)
33-
// This test is broken
34-
bt.fails(`blockhashNonConstArg_Constantinople`, "Broken test")
3533
// Slow tests
3634
bt.slow(`^bcExploitTest/DelegateCallSpam.json`)
3735
bt.slow(`^bcExploitTest/ShanghaiLove.json`)
@@ -40,6 +38,12 @@ func TestBlockchain(t *testing.T) {
4038
bt.slow(`^bcGasPricerTest/RPC_API_Test.json`)
4139
bt.slow(`^bcWalletTest/`)
4240

41+
// Still failing tests that we need to look into
42+
//bt.fails(`^bcStateTests/suicideThenCheckBalance.json/suicideThenCheckBalance_Constantinople`, "TODO: investigate")
43+
//bt.fails(`^bcStateTests/suicideStorageCheckVCreate2.json/suicideStorageCheckVCreate2_Constantinople`, "TODO: investigate")
44+
//bt.fails(`^bcStateTests/suicideStorageCheckVCreate.json/suicideStorageCheckVCreate_Constantinople`, "TODO: investigate")
45+
//bt.fails(`^bcStateTests/suicideStorageCheck.json/suicideStorageCheck_Constantinople`, "TODO: investigate")
46+
4347
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
4448
if err := bt.checkFailure(t, name, test.Run()); err != nil {
4549
t.Error(err)

‎tests/block_test_util.go‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/ethereum/go-ethereum/common"
2828
"github.com/ethereum/go-ethereum/common/hexutil"
2929
"github.com/ethereum/go-ethereum/common/math"
30+
"github.com/ethereum/go-ethereum/consensus"
3031
"github.com/ethereum/go-ethereum/consensus/ethash"
3132
"github.com/ethereum/go-ethereum/core"
3233
"github.com/ethereum/go-ethereum/core/state"
@@ -48,12 +49,13 @@ func (t *BlockTest) UnmarshalJSON(in []byte) error {
4849
}
4950

5051
type btJSON struct {
51-
Blocks []btBlock `json:"blocks"`
52-
Genesis btHeader `json:"genesisBlockHeader"`
53-
Pre core.GenesisAlloc `json:"pre"`
54-
Post core.GenesisAlloc `json:"postState"`
55-
BestBlock common.UnprefixedHash `json:"lastblockhash"`
56-
Network string `json:"network"`
52+
Blocks []btBlock `json:"blocks"`
53+
Genesis btHeader `json:"genesisBlockHeader"`
54+
Pre core.GenesisAlloc `json:"pre"`
55+
Post core.GenesisAlloc `json:"postState"`
56+
BestBlock common.UnprefixedHash `json:"lastblockhash"`
57+
Network string `json:"network"`
58+
SealEngine string `json:"sealEngine"`
5759
}
5860

5961
type btBlock struct {
@@ -110,8 +112,13 @@ func (t *BlockTest) Run() error {
110112
if gblock.Root() != t.json.Genesis.StateRoot {
111113
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6])
112114
}
113-
114-
chain, err := core.NewBlockChain(db, nil, config, ethash.NewShared(), vm.Config{}, nil)
115+
var engine consensus.Engine
116+
if t.json.SealEngine == "NoProof" {
117+
engine = ethash.NewFaker()
118+
} else {
119+
engine = ethash.NewShared()
120+
}
121+
chain, err := core.NewBlockChain(db, nil, config, engine, vm.Config{}, nil)
115122
if err != nil {
116123
return err
117124
}

‎tests/difficulty_test.go‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,6 @@ var (
3636
EIP158Block: big.NewInt(2675000),
3737
ByzantiumBlock: big.NewInt(4370000),
3838
}
39-
40-
// Ropsten without the Constantinople bump in bomb delay
41-
RopstenNoConstantinople = params.ChainConfig{
42-
ChainID: big.NewInt(3),
43-
HomesteadBlock: big.NewInt(0),
44-
DAOForkBlock: nil,
45-
DAOForkSupport: true,
46-
EIP150Block: big.NewInt(0),
47-
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
48-
EIP155Block: big.NewInt(10),
49-
EIP158Block: big.NewInt(10),
50-
ByzantiumBlock: big.NewInt(1700000),
51-
ConstantinopleBlock: nil,
52-
}
5339
)
5440

5541
func TestDifficulty(t *testing.T) {
@@ -69,7 +55,7 @@ func TestDifficulty(t *testing.T) {
6955
dt.skipLoad("difficultyMorden\\.json")
7056
dt.skipLoad("difficultyOlimpic\\.json")
7157

72-
dt.config("Ropsten", RopstenNoConstantinople)
58+
dt.config("Ropsten", *params.TestnetChainConfig)
7359
dt.config("Morden", *params.TestnetChainConfig)
7460
dt.config("Frontier", params.ChainConfig{})
7561

@@ -84,6 +70,9 @@ func TestDifficulty(t *testing.T) {
8470
dt.config("Frontier", *params.TestnetChainConfig)
8571
dt.config("MainNetwork", mainnetChainConfig)
8672
dt.config("CustomMainNetwork", mainnetChainConfig)
73+
dt.config("Constantinople", params.ChainConfig{
74+
ConstantinopleBlock: big.NewInt(0),
75+
})
8776
dt.config("difficulty.json", mainnetChainConfig)
8877

8978
dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) {

‎tests/state_test.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ func TestState(t *testing.T) {
4545
// Expected failures:
4646
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/EIP158`, "bug in test")
4747
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/Byzantium`, "bug in test")
48+
st.fails(`^stRevertTest/RevertPrecompiledTouch.json/Constantinople`, "bug in test")
4849

4950
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
5051
for _, subtest := range test.Subtests() {
5152
subtest := subtest
52-
if subtest.Fork == "Constantinople" {
53-
// Skipping constantinople due to net sstore gas changes affecting all tests
54-
continue
55-
}
5653
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
5754
name := name + "/" + key
5855
t.Run(key, func(t *testing.T) {

‎tests/testdata‎

Submodule testdata updated 13705 files

0 commit comments

Comments
 (0)