From 98caf5d39e00d166aa87bdbba767ae38da27d22e Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Thu, 17 Oct 2024 22:28:45 +0700 Subject: [PATCH] fix remaining tests --- cmd/geth/genesis_test.go | 6 +++--- core/block_validator_test.go | 5 +++-- tests/block_test_util.go | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/geth/genesis_test.go b/cmd/geth/genesis_test.go index 2766be2deb..f5d21cc00b 100644 --- a/cmd/geth/genesis_test.go +++ b/cmd/geth/genesis_test.go @@ -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 { diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 03e2079b10..8af4057693 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -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() }) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index b0a31a6972..28f482e79c 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -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 {