Skip to content

Commit a477ec5

Browse files
JonathanOppenheimeralarso16StephenButtolph
authored
sync: coreth PR #1361: test: Fix state sync flakes (#1859)
Signed-off-by: Austin Larson <[email protected]> Co-authored-by: Austin Larson <[email protected]> Co-authored-by: Stephen Buttolph <[email protected]>
1 parent c576302 commit a477ec5

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

scripts/known_flakes.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ TestChainIndexerWithChildren
22
TestClientCancelWebsocket
33
TestClientWebsocketLargeMessage
44
TestMempoolEthTxsAppGossipHandling
5-
TestResumeSyncAccountsTrieInterrupted
6-
TestResyncNewRootAfterDeletes
75
TestTransactionSkipIndexing
86
TestVMShutdownWhileSyncing
97
TestWaitDeployedCornerCases

sync/statesync/sync_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func TestCancelSync(t *testing.T) {
228228
// function which returns [errInterrupted] after passing through [numRequests]
229229
// leafs requests for [root].
230230
type interruptLeafsIntercept struct {
231-
numRequests uint32
231+
numRequests atomic.Uint32
232232
interruptAfter uint32
233233
root common.Hash
234234
}
@@ -238,7 +238,7 @@ type interruptLeafsIntercept struct {
238238
// After that, all requests for leafs from [root] return [errInterrupted].
239239
func (i *interruptLeafsIntercept) getLeafsIntercept(request message.LeafsRequest, response message.LeafsResponse) (message.LeafsResponse, error) {
240240
if request.Root == i.root {
241-
if numRequests := atomic.AddUint32(&i.numRequests, 1); numRequests > i.interruptAfter {
241+
if numRequests := i.numRequests.Add(1); numRequests > i.interruptAfter {
242242
return message.LeafsResponse{}, errInterrupted
243243
}
244244
}
@@ -263,7 +263,7 @@ func TestResumeSyncAccountsTrieInterrupted(t *testing.T) {
263263
GetLeafsIntercept: intercept.getLeafsIntercept,
264264
})
265265

266-
require.Equal(t, uint32(2), intercept.numRequests)
266+
require.GreaterOrEqual(t, intercept.numRequests.Load(), uint32(2))
267267

268268
testSync(t, syncTest{
269269
prepareForTest: func(*testing.T, *rand.Rand) (ethdb.Database, ethdb.Database, *triedb.Database, common.Hash) {

0 commit comments

Comments
 (0)