aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2018-10-16 06:26:47 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-10-16 06:26:47 +0800
commit60827dc50fc0892f63fc79704c57b45cf34f991e (patch)
tree351d66c284989acde5f368f1e5f29890ce96894b
parent2e98631c5e5724bea1a29b877929b4911bf50b86 (diff)
downloadgo-tangerine-60827dc50fc0892f63fc79704c57b45cf34f991e.tar.gz
go-tangerine-60827dc50fc0892f63fc79704c57b45cf34f991e.tar.zst
go-tangerine-60827dc50fc0892f63fc79704c57b45cf34f991e.zip
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.
-rw-r--r--tests/block_test.go8
-rw-r--r--tests/block_test_util.go23
-rw-r--r--tests/difficulty_test.go19
-rw-r--r--tests/state_test.go5
m---------tests/testdata0
5 files changed, 26 insertions, 29 deletions
diff --git a/tests/block_test.go b/tests/block_test.go
index 8315728a6..711a3f869 100644
--- a/tests/block_test.go
+++ b/tests/block_test.go
@@ -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)
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index 427a94958..12cba3244 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -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
}
diff --git a/tests/difficulty_test.go b/tests/difficulty_test.go
index 56c3fc297..fde9db3ad 100644
--- a/tests/difficulty_test.go
+++ b/tests/difficulty_test.go
@@ -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) {
diff --git a/tests/state_test.go b/tests/state_test.go
index c52e9abb8..ad77e4f33 100644
--- a/tests/state_test.go
+++ b/tests/state_test.go
@@ -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) {
diff --git a/tests/testdata b/tests/testdata
-Subproject ad2184adca367c0b68c65b44519dba16e1d0b9e
+Subproject 95a309203890e6244c6d4353ca411671973c13b