fix remaining tests

This commit is contained in:
Jared Wasinger 2024-10-17 22:28:45 +07:00
parent de84a27bcf
commit 98caf5d39e
3 changed files with 11 additions and 5 deletions

View file

@ -42,7 +42,7 @@ var customGenesisTests = []struct {
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"config": {
"terminalTotalDifficulty": "0xffffffffffffffff"
"terminalTotalDifficulty": 0
}
}`,
query: "eth.getBlock(0).nonce",
@ -64,7 +64,7 @@ var customGenesisTests = []struct {
"homesteadBlock" : 42,
"daoForkBlock" : 141,
"daoForkSupport" : true,
"terminalTotalDifficulty": "0xffffffffffffffff"
"terminalTotalDifficulty": 0
}
}`,
query: "eth.getBlock(0).nonce",
@ -115,7 +115,7 @@ func TestCustomBackend(t *testing.T) {
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"config": {
"terminalTotalDifficulty": "0xffffffffffffffff"
"terminalTotalDifficulty": 0
}
}`
type backendTest struct {

View file

@ -113,9 +113,11 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
}
copy(gspec.ExtraData[32:], addr[:])
// chain_maker has no blockchain to retrieve the TTD from, setting to nil
// is a hack to signal it to generate pre-merge blocks
gspec.Config.TerminalTotalDifficulty = nil
td := 0
genDb, blocks, _ := GenerateChainWithGenesis(gspec, engine, 8, nil)
gspec.Config.TerminalTotalDifficulty = big.NewInt(1000)
for i, block := range blocks {
header := block.Header()
@ -147,7 +149,6 @@ func testHeaderVerificationForMerging(t *testing.T, isClique bool) {
}
preBlocks = blocks
gspec.Config.TerminalTotalDifficulty = big.NewInt(int64(td))
t.Logf("Set ttd to %v\n", gspec.Config.TerminalTotalDifficulty)
postBlocks, _ = GenerateChain(gspec.Config, preBlocks[len(preBlocks)-1], engine, genDb, 8, func(i int, gen *BlockGen) {
gen.SetPoS()
})

View file

@ -129,6 +129,11 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, witness bool, tracer *t
}
// Commit genesis state
gspec := t.genesis(config)
// if ttd is not specified, set an arbitrary huge value
if gspec.Config.TerminalTotalDifficulty == nil {
gspec.Config.TerminalTotalDifficulty = big.NewInt(math.MaxInt64)
}
triedb := triedb.NewDatabase(db, tconf)
gblock, err := gspec.Commit(db, triedb)
if err != nil {