mirror of https://github.com/status-im/op-geth.git
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.
This commit is contained in:
parent
2e98631c5e
commit
60827dc50f
|
@ -30,8 +30,6 @@ func TestBlockchain(t *testing.T) {
|
|||
bt.skipLoad(`^bcForgedTest/bcForkUncle\.json`)
|
||||
bt.skipLoad(`^bcMultiChainTest/(ChainAtoChainB_blockorder|CallContractFromNotBestBlock)`)
|
||||
bt.skipLoad(`^bcTotalDifficultyTest/(lotsOfLeafs|lotsOfBranches|sideChainWithMoreTransactions)`)
|
||||
// This test is broken
|
||||
bt.fails(`blockhashNonConstArg_Constantinople`, "Broken test")
|
||||
// Slow tests
|
||||
bt.slow(`^bcExploitTest/DelegateCallSpam.json`)
|
||||
bt.slow(`^bcExploitTest/ShanghaiLove.json`)
|
||||
|
@ -40,6 +38,12 @@ func TestBlockchain(t *testing.T) {
|
|||
bt.slow(`^bcGasPricerTest/RPC_API_Test.json`)
|
||||
bt.slow(`^bcWalletTest/`)
|
||||
|
||||
// Still failing tests that we need to look into
|
||||
//bt.fails(`^bcStateTests/suicideThenCheckBalance.json/suicideThenCheckBalance_Constantinople`, "TODO: investigate")
|
||||
//bt.fails(`^bcStateTests/suicideStorageCheckVCreate2.json/suicideStorageCheckVCreate2_Constantinople`, "TODO: investigate")
|
||||
//bt.fails(`^bcStateTests/suicideStorageCheckVCreate.json/suicideStorageCheckVCreate_Constantinople`, "TODO: investigate")
|
||||
//bt.fails(`^bcStateTests/suicideStorageCheck.json/suicideStorageCheck_Constantinople`, "TODO: investigate")
|
||||
|
||||
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
|
||||
if err := bt.checkFailure(t, name, test.Run()); err != nil {
|
||||
t.Error(err)
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
|
@ -48,12 +49,13 @@ func (t *BlockTest) UnmarshalJSON(in []byte) error {
|
|||
}
|
||||
|
||||
type btJSON struct {
|
||||
Blocks []btBlock `json:"blocks"`
|
||||
Genesis btHeader `json:"genesisBlockHeader"`
|
||||
Pre core.GenesisAlloc `json:"pre"`
|
||||
Post core.GenesisAlloc `json:"postState"`
|
||||
BestBlock common.UnprefixedHash `json:"lastblockhash"`
|
||||
Network string `json:"network"`
|
||||
Blocks []btBlock `json:"blocks"`
|
||||
Genesis btHeader `json:"genesisBlockHeader"`
|
||||
Pre core.GenesisAlloc `json:"pre"`
|
||||
Post core.GenesisAlloc `json:"postState"`
|
||||
BestBlock common.UnprefixedHash `json:"lastblockhash"`
|
||||
Network string `json:"network"`
|
||||
SealEngine string `json:"sealEngine"`
|
||||
}
|
||||
|
||||
type btBlock struct {
|
||||
|
@ -110,8 +112,13 @@ func (t *BlockTest) Run() error {
|
|||
if gblock.Root() != t.json.Genesis.StateRoot {
|
||||
return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6])
|
||||
}
|
||||
|
||||
chain, err := core.NewBlockChain(db, nil, config, ethash.NewShared(), vm.Config{}, nil)
|
||||
var engine consensus.Engine
|
||||
if t.json.SealEngine == "NoProof" {
|
||||
engine = ethash.NewFaker()
|
||||
} else {
|
||||
engine = ethash.NewShared()
|
||||
}
|
||||
chain, err := core.NewBlockChain(db, nil, config, engine, vm.Config{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -36,20 +36,6 @@ var (
|
|||
EIP158Block: big.NewInt(2675000),
|
||||
ByzantiumBlock: big.NewInt(4370000),
|
||||
}
|
||||
|
||||
// Ropsten without the Constantinople bump in bomb delay
|
||||
RopstenNoConstantinople = params.ChainConfig{
|
||||
ChainID: big.NewInt(3),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
|
||||
EIP155Block: big.NewInt(10),
|
||||
EIP158Block: big.NewInt(10),
|
||||
ByzantiumBlock: big.NewInt(1700000),
|
||||
ConstantinopleBlock: nil,
|
||||
}
|
||||
)
|
||||
|
||||
func TestDifficulty(t *testing.T) {
|
||||
|
@ -69,7 +55,7 @@ func TestDifficulty(t *testing.T) {
|
|||
dt.skipLoad("difficultyMorden\\.json")
|
||||
dt.skipLoad("difficultyOlimpic\\.json")
|
||||
|
||||
dt.config("Ropsten", RopstenNoConstantinople)
|
||||
dt.config("Ropsten", *params.TestnetChainConfig)
|
||||
dt.config("Morden", *params.TestnetChainConfig)
|
||||
dt.config("Frontier", params.ChainConfig{})
|
||||
|
||||
|
@ -84,6 +70,9 @@ func TestDifficulty(t *testing.T) {
|
|||
dt.config("Frontier", *params.TestnetChainConfig)
|
||||
dt.config("MainNetwork", mainnetChainConfig)
|
||||
dt.config("CustomMainNetwork", mainnetChainConfig)
|
||||
dt.config("Constantinople", params.ChainConfig{
|
||||
ConstantinopleBlock: big.NewInt(0),
|
||||
})
|
||||
dt.config("difficulty.json", mainnetChainConfig)
|
||||
|
||||
dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) {
|
||||
|
|
|
@ -45,14 +45,11 @@ func TestState(t *testing.T) {
|
|||
// Expected failures:
|
||||
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/EIP158`, "bug in test")
|
||||
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/Byzantium`, "bug in test")
|
||||
st.fails(`^stRevertTest/RevertPrecompiledTouch.json/Constantinople`, "bug in test")
|
||||
|
||||
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
|
||||
for _, subtest := range test.Subtests() {
|
||||
subtest := subtest
|
||||
if subtest.Fork == "Constantinople" {
|
||||
// Skipping constantinople due to net sstore gas changes affecting all tests
|
||||
continue
|
||||
}
|
||||
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
|
||||
name := name + "/" + key
|
||||
t.Run(key, func(t *testing.T) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ad2184adca367c0b68c65b44519dba16e1d0b9e2
|
||||
Subproject commit 95a309203890e6244c6d4353ca411671973c13b5
|
Loading…
Reference in New Issue