From fde4d542231b0392fa3cfc6e81502502c93c903a Mon Sep 17 00:00:00 2001 From: zzzckck <152148891+zzzckck@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:14:52 +0800 Subject: [PATCH] UT: random failure of TestSnapSyncWithBlobs (#2519) this case failed randomly in github CI, the ratio of around 20% but can not be reproduced locally by: ``` go test -p 1 -v -run TestSnapSyncWithBlobs -count 100 ``` there could be a potential risk between `runEthPeer` and `runSnapExtension`,as they shared the same handler.peers. Add extra wait time for `runEthPeer` to resolve it. And same for another UT: testBroadcastBlock --- eth/handler_eth_test.go | 3 +++ eth/sync_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 534b72b865..c35bf0f4ce 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -633,6 +633,9 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) { go source.handler.runEthPeer(sourcePeer, func(peer *eth.Peer) error { return eth.Handle((*ethHandler)(source.handler), peer) }) + // Wait a bit for the above handlers to start + time.Sleep(100 * time.Millisecond) + if err := sinkPeer.Handshake(1, td, genesis.Hash(), genesis.Hash(), forkid.NewIDWithChain(source.chain), forkid.NewFilter(source.chain), nil); err != nil { t.Fatalf("failed to run protocol handshake") } diff --git a/eth/sync_test.go b/eth/sync_test.go index d846e06abb..195d2fd2ae 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -151,6 +151,8 @@ func testChainSyncWithBlobs(t *testing.T, mode downloader.SyncMode, preCancunBlk go full.handler.runEthPeer(fullPeerEth, func(peer *eth.Peer) error { return eth.Handle((*ethHandler)(full.handler), peer) }) + // Wait a bit for the above handlers to start + time.Sleep(250 * time.Millisecond) emptyPipeSnap, fullPipeSnap := p2p.MsgPipe() defer emptyPipeSnap.Close()