Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some flaky tests #1379

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,11 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
bc.triegc.Push(root, number)
break
}
go triedb.Dereference(root.(common.Hash))
wg.Add(1)
go func() {
triedb.Dereference(root.(common.Hash))
wg.Done()
brilliant-lx marked this conversation as resolved.
Show resolved Hide resolved
}()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func (s *StateDB) StopPrefetcher() {
s.prefetcherLock.Lock()
if s.prefetcher != nil {
s.prefetcher.close()
s.prefetcher = nil
brilliant-lx marked this conversation as resolved.
Show resolved Hide resolved
}
s.prefetcherLock.Unlock()
}
Expand Down
6 changes: 3 additions & 3 deletions eth/protocols/diff/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ func testGetDiffLayers(t *testing.T, protocol uint) {
missDiffPackets := make([]FullDiffLayersPacket, 0)

for i := 0; i < 100; i++ {
number := uint64(rand.Int63n(1024))
if number == 0 {
continue
// Find a non 0 random number
var number uint64
for ; number == 0; number = uint64(rand.Int63n(1024)) {
}
foundHash := backend.chain.GetCanonicalHash(number + 1024)
missHash := backend.chain.GetCanonicalHash(number)
Expand Down