From a376f4b93e9024ef867af7fb7625489a9e6fe359 Mon Sep 17 00:00:00 2001 From: Francis Li Date: Mon, 21 Oct 2024 11:40:57 -0700 Subject: [PATCH] Add more transactions into blocks --- eth/api_debug_test.go | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/eth/api_debug_test.go b/eth/api_debug_test.go index c398680b14..28e04a0220 100644 --- a/eth/api_debug_test.go +++ b/eth/api_debug_test.go @@ -234,16 +234,43 @@ func TestStorageRangeAt(t *testing.T) { func TestExecutionWitness(t *testing.T) { t.Parallel() + var ( + db = rawdb.NewMemoryDatabase() + gspec = &core.Genesis{ + Config: params.TestChainConfig, + Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000000000000)}}, + } + chain, _ = core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil) + signer = types.LatestSigner(gspec.Config) + ) // Create a database pre-initialize with a genesis block - db := rawdb.NewMemoryDatabase() - gspec := &core.Genesis{ - Config: params.TestChainConfig, - Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, - } - chain, _ := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil) blockNum := 10 - _, bs, _ := core.GenerateChainWithGenesis(gspec, ethash.NewFaker(), blockNum, nil) + _, bs, _ := core.GenerateChainWithGenesis(gspec, ethash.NewFaker(), blockNum, func(i int, g *core.BlockGen) { + if i == 0 { + return + } + + // add more transactions to the block + for j := 0; j < 10; j++ { + tx, err := types.SignNewTx(testKey, signer, &types.DynamicFeeTx{ + ChainID: gspec.Config.ChainID, + Nonce: uint64((i-1)*10 + j), + GasTipCap: common.Big0, + GasFeeCap: g.PrevBlock(0).BaseFee(), + Gas: 50000, + To: &common.Address{0xaa}, + Value: big.NewInt(int64(i)), + Data: nil, + AccessList: nil, + }) + if err != nil { + t.Fatalf("error creating tx: %v", err) + } + g.AddTx(tx) + } + }) + if _, err := chain.InsertChain(bs); err != nil { panic(err) }