mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
tests: Updated, now ignores difficulty below minimum
This commit is contained in:
parent
e7ce621ebf
commit
169b45e78f
2 changed files with 33 additions and 22 deletions
|
|
@ -1,3 +1,20 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -35,22 +52,18 @@ type difficultyTestMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Values taken from
|
mainnetChainConfig = ¶ms.ChainConfig{
|
||||||
// https://github.com/ethereum/cpp-ethereum/blob/6cb2c852700024daf79e7cb31e4c12ffb7d85537/test/unittests/libethcore/difficulty.cpp#L212
|
|
||||||
// and
|
|
||||||
// https://github.com/ethereum/cpp-ethereum/blob/develop/libethashseal/genesis/test/mainNetworkTest.cpp
|
|
||||||
|
|
||||||
customMainnetConfig = ¶ms.ChainConfig{
|
|
||||||
ChainId: big.NewInt(1),
|
ChainId: big.NewInt(1),
|
||||||
HomesteadBlock: big.NewInt(0x118c30),
|
HomesteadBlock: big.NewInt(1150000),
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: big.NewInt(1920000),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0x259518),
|
EIP150Block: big.NewInt(2463000),
|
||||||
EIP155Block: big.NewInt(0x259518),
|
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
|
||||||
EIP158Block: big.NewInt(0x28d138),
|
EIP155Block: big.NewInt(2675000),
|
||||||
ByzantiumBlock: big.NewInt(0x2dc6c0),
|
EIP158Block: big.NewInt(2675000),
|
||||||
}
|
ByzantiumBlock: big.NewInt(4370000), // Don't enable yet
|
||||||
|
|
||||||
|
}
|
||||||
homesteadConfig = ¶ms.ChainConfig{
|
homesteadConfig = ¶ms.ChainConfig{
|
||||||
ChainId: big.NewInt(1),
|
ChainId: big.NewInt(1),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: big.NewInt(0),
|
||||||
|
|
@ -99,12 +112,10 @@ func TestDifficulty(t *testing.T) {
|
||||||
dt.skipLoad("difficultyCustomHomestead\\.json")
|
dt.skipLoad("difficultyCustomHomestead\\.json")
|
||||||
dt.skipLoad("difficultyMorden\\.json")
|
dt.skipLoad("difficultyMorden\\.json")
|
||||||
dt.skipLoad("difficultyOlimpic\\.json")
|
dt.skipLoad("difficultyOlimpic\\.json")
|
||||||
// Contains erroneously generated uncle-values : "0x01" -should be hashes
|
|
||||||
dt.skipLoad("difficultyCustomMainNetwork\\.json")
|
|
||||||
|
|
||||||
dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *difficultyTest) {
|
dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *difficultyTest) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
config := params.MainnetChainConfig
|
config := mainnetChainConfig
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(name, "Ropsten") || strings.Contains(name, "Morden"):
|
case strings.Contains(name, "Ropsten") || strings.Contains(name, "Morden"):
|
||||||
|
|
@ -115,10 +126,11 @@ func TestDifficulty(t *testing.T) {
|
||||||
config = homesteadConfig
|
config = homesteadConfig
|
||||||
case strings.Contains(name, "Byzantium"):
|
case strings.Contains(name, "Byzantium"):
|
||||||
config = byzantiumConfig
|
config = byzantiumConfig
|
||||||
case strings.Contains(name, "CustomMainNetwork"):
|
|
||||||
config = customMainnetConfig
|
|
||||||
}
|
}
|
||||||
|
if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 {
|
||||||
|
t.Skip("difficulty below minimum")
|
||||||
|
return
|
||||||
|
}
|
||||||
parentNumber := big.NewInt(int64(test.CurrentBlockNumber - 1))
|
parentNumber := big.NewInt(int64(test.CurrentBlockNumber - 1))
|
||||||
parent := &types.Header{
|
parent := &types.Header{
|
||||||
Difficulty: test.ParentDifficulty,
|
Difficulty: test.ParentDifficulty,
|
||||||
|
|
@ -131,8 +143,7 @@ func TestDifficulty(t *testing.T) {
|
||||||
exp := test.CurrentDifficulty
|
exp := test.CurrentDifficulty
|
||||||
|
|
||||||
if actual.Cmp(exp) != 0 {
|
if actual.Cmp(exp) != 0 {
|
||||||
|
t.Errorf("parent[time %v diff %v unclehash:%x] child[time %v number %v] diff %v != expected %v",
|
||||||
t.Errorf("parent[time %v diff %v #uncles:%v] child[time %v number %v] diff %v != expected %v",
|
|
||||||
test.ParentTimestamp, test.ParentDifficulty, test.UncleHash,
|
test.ParentTimestamp, test.ParentDifficulty, test.UncleHash,
|
||||||
test.CurrentTimestamp, test.CurrentBlockNumber, actual, exp)
|
test.CurrentTimestamp, test.CurrentBlockNumber, actual, exp)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit da12f07176a1657e75fc251c8fb865e817b0d4a6
|
Subproject commit 37f555fbc091fbf761aa6f02227132fb31f0681c
|
||||||
Loading…
Reference in a new issue