mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
fix some tests. relax check that ttd is not nil in IsTTDReached: consensus engine creation ensures this.
This commit is contained in:
parent
6be6b8a520
commit
de84a27bcf
4 changed files with 14 additions and 13 deletions
|
|
@ -29,7 +29,7 @@ var customGenesisTests = []struct {
|
||||||
query string
|
query string
|
||||||
result string
|
result string
|
||||||
}{
|
}{
|
||||||
// Genesis file with an empty chain configuration (ensure missing fields work)
|
// Genesis file with a mostly-empty chain configuration (ensure missing fields work)
|
||||||
{
|
{
|
||||||
genesis: `{
|
genesis: `{
|
||||||
"alloc" : {},
|
"alloc" : {},
|
||||||
|
|
@ -41,7 +41,9 @@ var customGenesisTests = []struct {
|
||||||
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"timestamp" : "0x00",
|
"timestamp" : "0x00",
|
||||||
"config": {}
|
"config": {
|
||||||
|
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||||
|
}
|
||||||
}`,
|
}`,
|
||||||
query: "eth.getBlock(0).nonce",
|
query: "eth.getBlock(0).nonce",
|
||||||
result: "0x0000000000001338",
|
result: "0x0000000000001338",
|
||||||
|
|
@ -61,7 +63,8 @@ var customGenesisTests = []struct {
|
||||||
"config" : {
|
"config" : {
|
||||||
"homesteadBlock" : 42,
|
"homesteadBlock" : 42,
|
||||||
"daoForkBlock" : 141,
|
"daoForkBlock" : 141,
|
||||||
"daoForkSupport" : true
|
"daoForkSupport" : true,
|
||||||
|
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
query: "eth.getBlock(0).nonce",
|
query: "eth.getBlock(0).nonce",
|
||||||
|
|
@ -111,7 +114,9 @@ func TestCustomBackend(t *testing.T) {
|
||||||
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
"timestamp" : "0x00",
|
"timestamp" : "0x00",
|
||||||
"config": {}
|
"config": {
|
||||||
|
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||||
|
}
|
||||||
}`
|
}`
|
||||||
type backendTest struct {
|
type backendTest struct {
|
||||||
initArgs []string
|
initArgs []string
|
||||||
|
|
|
||||||
3
cmd/geth/testdata/clique.json
vendored
3
cmd/geth/testdata/clique.json
vendored
|
|
@ -8,6 +8,7 @@
|
||||||
"byzantiumBlock": 0,
|
"byzantiumBlock": 0,
|
||||||
"constantinopleBlock": 0,
|
"constantinopleBlock": 0,
|
||||||
"petersburgBlock": 0,
|
"petersburgBlock": 0,
|
||||||
|
"terminalTotalDifficulty": 0,
|
||||||
"clique": {
|
"clique": {
|
||||||
"period": 5,
|
"period": 5,
|
||||||
"epoch": 30000
|
"epoch": 30000
|
||||||
|
|
@ -21,4 +22,4 @@
|
||||||
"balance": "300000"
|
"balance": "300000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ package beacon
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
||||||
|
|
@ -32,6 +30,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Proof-of-stake protocol constants.
|
// Proof-of-stake protocol constants.
|
||||||
|
|
@ -115,9 +114,6 @@ func errOut(n int, err error) chan error {
|
||||||
func (beacon *Beacon) splitHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) ([]*types.Header, []*types.Header, error) {
|
func (beacon *Beacon) splitHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) ([]*types.Header, []*types.Header, error) {
|
||||||
// TTD is not defined yet, all headers should be in legacy format.
|
// TTD is not defined yet, all headers should be in legacy format.
|
||||||
ttd := chain.Config().TerminalTotalDifficulty
|
ttd := chain.Config().TerminalTotalDifficulty
|
||||||
if ttd == nil {
|
|
||||||
return headers, nil, nil
|
|
||||||
}
|
|
||||||
ptd := chain.GetTd(headers[0].ParentHash, headers[0].Number.Uint64()-1)
|
ptd := chain.GetTd(headers[0].ParentHash, headers[0].Number.Uint64()-1)
|
||||||
if ptd == nil {
|
if ptd == nil {
|
||||||
return nil, nil, consensus.ErrUnknownAncestor
|
return nil, nil, consensus.ErrUnknownAncestor
|
||||||
|
|
@ -494,9 +490,6 @@ func (beacon *Beacon) SetThreads(threads int) {
|
||||||
// It depends on the parentHash already being stored in the database.
|
// It depends on the parentHash already being stored in the database.
|
||||||
// If the parentHash is not stored in the database a UnknownAncestor error is returned.
|
// If the parentHash is not stored in the database a UnknownAncestor error is returned.
|
||||||
func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error) {
|
func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error) {
|
||||||
if chain.Config().TerminalTotalDifficulty == nil {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
td := chain.GetTd(parentHash, parentNumber)
|
td := chain.GetTd(parentHash, parentNumber)
|
||||||
if td == nil {
|
if td == nil {
|
||||||
return false, consensus.ErrUnknownAncestor
|
return false, consensus.ErrUnknownAncestor
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,8 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
|
||||||
|
|
||||||
td := 0
|
td := 0
|
||||||
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil)
|
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil)
|
||||||
|
gspec.Config.TerminalTotalDifficulty = big.NewInt(1000)
|
||||||
|
|
||||||
for i, block := range blocks {
|
for i, block := range blocks {
|
||||||
header := block.Header()
|
header := block.Header()
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue