|
| 1 | +package miner |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/ethereum/go-ethereum/consensus/clique" |
| 7 | + "github.com/ethereum/go-ethereum/core/rawdb" |
| 8 | + "github.com/ethereum/go-ethereum/core/types" |
| 9 | + "github.com/ethereum/go-ethereum/params" |
| 10 | + "github.com/stretchr/testify/assert" |
| 11 | +) |
| 12 | + |
| 13 | +func testGenerateWorker(t *testing.T, txCount int) *worker { |
| 14 | + t.Parallel() |
| 15 | + var ( |
| 16 | + db = rawdb.NewMemoryDatabase() |
| 17 | + config = *params.AllCliqueProtocolChanges |
| 18 | + ) |
| 19 | + config.Taiko = true |
| 20 | + config.Clique = ¶ms.CliqueConfig{Period: 1, Epoch: 30000} |
| 21 | + engine := clique.New(config.Clique, db) |
| 22 | + |
| 23 | + w, b := newTestWorker(t, &config, engine, db, 0) |
| 24 | + //defer w.close() |
| 25 | + |
| 26 | + for i := 0; i < txCount; i++ { |
| 27 | + b.txPool.Add([]*types.Transaction{b.newRandomTx(true)}, true, false) |
| 28 | + b.txPool.Add([]*types.Transaction{b.newRandomTx(false)}, true, false) |
| 29 | + } |
| 30 | + |
| 31 | + return w |
| 32 | +} |
| 33 | + |
| 34 | +func TestBuildTransactionsLists(t *testing.T) { |
| 35 | + w := testGenerateWorker(t, 1000) |
| 36 | + defer w.close() |
| 37 | + |
| 38 | + maxBytesPerTxList := (params.BlobTxBytesPerFieldElement - 1) * params.BlobTxFieldElementsPerBlob |
| 39 | + txLst, err := w.BuildTransactionsLists( |
| 40 | + testBankAddress, |
| 41 | + nil, |
| 42 | + 240_000_000, |
| 43 | + uint64(maxBytesPerTxList), |
| 44 | + nil, |
| 45 | + 1, |
| 46 | + 0) |
| 47 | + assert.NoError(t, err) |
| 48 | + assert.LessOrEqual(t, 1, len(txLst)) |
| 49 | + assert.LessOrEqual(t, txLst[0].BytesLength, uint64(maxBytesPerTxList)) |
| 50 | +} |
0 commit comments