forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(taiko_api): reduce the frequency of
zlib
compression when fetc…
…hing txpool content (#323) * reduce the frequency of zlib compression when fetching txpool content * fix go import order * fix comment
- Loading branch information
1 parent
57b4454
commit d2d56b2
Showing
2 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package miner | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/consensus/clique" | ||
"github.com/ethereum/go-ethereum/core/rawdb" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/params" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func testGenerateWorker(t *testing.T, txCount int) *worker { | ||
t.Parallel() | ||
var ( | ||
db = rawdb.NewMemoryDatabase() | ||
config = *params.AllCliqueProtocolChanges | ||
) | ||
config.Taiko = true | ||
config.Clique = ¶ms.CliqueConfig{Period: 1, Epoch: 30000} | ||
engine := clique.New(config.Clique, db) | ||
|
||
w, b := newTestWorker(t, &config, engine, db, 0) | ||
//defer w.close() | ||
|
||
for i := 0; i < txCount; i++ { | ||
b.txPool.Add([]*types.Transaction{b.newRandomTx(true)}, true, false) | ||
b.txPool.Add([]*types.Transaction{b.newRandomTx(false)}, true, false) | ||
} | ||
|
||
return w | ||
} | ||
|
||
func TestBuildTransactionsLists(t *testing.T) { | ||
w := testGenerateWorker(t, 1000) | ||
defer w.close() | ||
|
||
maxBytesPerTxList := (params.BlobTxBytesPerFieldElement - 1) * params.BlobTxFieldElementsPerBlob | ||
txLst, err := w.BuildTransactionsLists( | ||
testBankAddress, | ||
nil, | ||
240_000_000, | ||
uint64(maxBytesPerTxList), | ||
nil, | ||
1, | ||
0) | ||
assert.NoError(t, err) | ||
assert.LessOrEqual(t, 1, len(txLst)) | ||
assert.LessOrEqual(t, txLst[0].BytesLength, uint64(maxBytesPerTxList)) | ||
} |