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
|
||||
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: `{
|
||||
"alloc" : {},
|
||||
|
|
@ -41,7 +41,9 @@ var customGenesisTests = []struct {
|
|||
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"timestamp" : "0x00",
|
||||
"config": {}
|
||||
"config": {
|
||||
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||
}
|
||||
}`,
|
||||
query: "eth.getBlock(0).nonce",
|
||||
result: "0x0000000000001338",
|
||||
|
|
@ -61,7 +63,8 @@ var customGenesisTests = []struct {
|
|||
"config" : {
|
||||
"homesteadBlock" : 42,
|
||||
"daoForkBlock" : 141,
|
||||
"daoForkSupport" : true
|
||||
"daoForkSupport" : true,
|
||||
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||
}
|
||||
}`,
|
||||
query: "eth.getBlock(0).nonce",
|
||||
|
|
@ -111,7 +114,9 @@ func TestCustomBackend(t *testing.T) {
|
|||
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"timestamp" : "0x00",
|
||||
"config": {}
|
||||
"config": {
|
||||
"terminalTotalDifficulty": "0xffffffffffffffff"
|
||||
}
|
||||
}`
|
||||
type backendTest struct {
|
||||
initArgs []string
|
||||
|
|
|
|||
3
cmd/geth/testdata/clique.json
vendored
3
cmd/geth/testdata/clique.json
vendored
|
|
@ -8,6 +8,7 @@
|
|||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"terminalTotalDifficulty": 0,
|
||||
"clique": {
|
||||
"period": 5,
|
||||
"epoch": 30000
|
||||
|
|
@ -21,4 +22,4 @@
|
|||
"balance": "300000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ package beacon
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
||||
|
|
@ -32,6 +30,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/holiman/uint256"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// 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) {
|
||||
// TTD is not defined yet, all headers should be in legacy format.
|
||||
ttd := chain.Config().TerminalTotalDifficulty
|
||||
if ttd == nil {
|
||||
return headers, nil, nil
|
||||
}
|
||||
ptd := chain.GetTd(headers[0].ParentHash, headers[0].Number.Uint64()-1)
|
||||
if ptd == nil {
|
||||
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.
|
||||
// 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) {
|
||||
if chain.Config().TerminalTotalDifficulty == nil {
|
||||
return false, nil
|
||||
}
|
||||
td := chain.GetTd(parentHash, parentNumber)
|
||||
if td == nil {
|
||||
return false, consensus.ErrUnknownAncestor
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
|
|||
|
||||
td := 0
|
||||
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil)
|
||||
gspec.Config.TerminalTotalDifficulty = big.NewInt(1000)
|
||||
|
||||
for i, block := range blocks {
|
||||
header := block.Header()
|
||||
if i > 0 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue