Skip to content

Commit b48399b

Browse files
holimanrjl493456442
authored andcommitted
eth/catalyst, trie/pathdb: fix flaky tests (ethereum#29571)
This change fixes three flaky tests `TestEth2AssembleBlock`,`TestEth2NewBlock`, `TestEth2PrepareAndGetPayload` and `TestDisable`. --------- Co-authored-by: Gary Rong <[email protected]>
1 parent 04c6903 commit b48399b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

eth/catalyst/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestEth2AssembleBlock(t *testing.T) {
112112
if err != nil {
113113
t.Fatalf("error signing transaction, err=%v", err)
114114
}
115-
ethservice.TxPool().Add([]*types.Transaction{tx}, true, false)
115+
ethservice.TxPool().Add([]*types.Transaction{tx}, true, true)
116116
blockParams := engine.PayloadAttributes{
117117
Timestamp: blocks[9].Time() + 5,
118118
}
@@ -189,7 +189,7 @@ func TestEth2PrepareAndGetPayload(t *testing.T) {
189189

190190
// Put the 10th block's tx in the pool and produce a new block
191191
txs := blocks[9].Transactions()
192-
ethservice.TxPool().Add(txs, true, false)
192+
ethservice.TxPool().Add(txs, true, true)
193193
blockParams := engine.PayloadAttributes{
194194
Timestamp: blocks[8].Time() + 5,
195195
}
@@ -310,13 +310,13 @@ func TestEth2NewBlock(t *testing.T) {
310310
statedb, _ := ethservice.BlockChain().StateAt(parent.Root())
311311
nonce := statedb.GetNonce(testAddr)
312312
tx, _ := types.SignTx(types.NewContractCreation(nonce, new(big.Int), 1000000, big.NewInt(2*params.InitialBaseFee), logCode), types.LatestSigner(ethservice.BlockChain().Config()), testKey)
313-
ethservice.TxPool().Add([]*types.Transaction{tx}, true, false)
313+
ethservice.TxPool().Add([]*types.Transaction{tx}, true, true)
314314

315315
execData, err := assembleWithTransactions(api, parent.Hash(), &engine.PayloadAttributes{
316316
Timestamp: parent.Time() + 5,
317317
}, 1)
318318
if err != nil {
319-
t.Fatalf("Failed to create the executable data %v", err)
319+
t.Fatalf("Failed to create the executable data, block %d: %v", i, err)
320320
}
321321
block, err := engine.ExecutableDataToBlock(*execData, nil, nil)
322322
if err != nil {

triedb/pathdb/database.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ func (db *Database) Enable(root common.Hash) error {
293293
// Ensure the provided state root matches the stored one.
294294
root = types.TrieRootHash(root)
295295
_, stored := rawdb.ReadAccountTrieNode(db.diskdb, nil)
296+
stored = types.TrieRootHash(stored)
296297
if stored != root {
297298
return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root)
298299
}

triedb/pathdb/database_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,13 @@ func TestDisable(t *testing.T) {
476476

477477
_, stored := rawdb.ReadAccountTrieNode(tester.db.diskdb, nil)
478478
if err := tester.db.Disable(); err != nil {
479-
t.Fatal("Failed to deactivate database")
479+
t.Fatalf("Failed to deactivate database: %v", err)
480480
}
481481
if err := tester.db.Enable(types.EmptyRootHash); err == nil {
482-
t.Fatalf("Invalid activation should be rejected")
482+
t.Fatal("Invalid activation should be rejected")
483483
}
484484
if err := tester.db.Enable(stored); err != nil {
485-
t.Fatal("Failed to activate database")
485+
t.Fatalf("Failed to activate database: %v", err)
486486
}
487487

488488
// Ensure journal is deleted from disk

0 commit comments

Comments
 (0)