Skip to content

Commit dc43ea8

Browse files
authored
tests: tune flaky tests that error in travis occasionally (#18508)
* tests: tune flaky tests that error in travis occasionally * tests: formatting
1 parent a50b471 commit dc43ea8

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎eth/fetcher/fetcher_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func verifyImportEvent(t *testing.T, imported chan *types.Block, arrive bool) {
244244
select {
245245
case <-imported:
246246
t.Fatalf("import invoked")
247-
case <-time.After(10 * time.Millisecond):
247+
case <-time.After(20 * time.Millisecond):
248248
}
249249
}
250250
}

‎miner/worker_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
224224
for i := 0; i < 2; i += 1 {
225225
select {
226226
case <-taskCh:
227-
case <-time.NewTimer(time.Second).C:
227+
case <-time.NewTimer(2 * time.Second).C:
228228
t.Error("new task timeout")
229229
}
230230
}

‎p2p/protocols/protocol_test.go‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,11 @@ func TestProtocolHook(t *testing.T) {
269269
if !testHook.send {
270270
t.Fatal("Expected a send message, but it is not")
271271
}
272-
if testHook.peer == nil || testHook.peer.ID() != tester.Nodes[0].ID() {
273-
t.Fatal("Expected peer ID to be set correctly, but it is not")
272+
if testHook.peer == nil {
273+
t.Fatal("Expected peer to be set, is nil")
274+
}
275+
if peerId := testHook.peer.ID(); peerId != tester.Nodes[0].ID() && peerId != tester.Nodes[1].ID() {
276+
t.Fatalf("Expected peer ID to be set correctly, but it is not (got %v, exp %v or %v", peerId, tester.Nodes[0].ID(), tester.Nodes[1].ID())
274277
}
275278
if testHook.size != 11 { //11 is the length of the encoded message
276279
t.Fatalf("Expected size to be %d, but it is %d ", 1, testHook.size)

‎p2p/protocols/reporter_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestReporter(t *testing.T) {
3939

4040
//setup the metrics
4141
log.Debug("Setting up metrics first time")
42-
reportInterval := 5 * time.Millisecond
42+
reportInterval := 2 * time.Millisecond
4343
metrics := SetupAccountingMetrics(reportInterval, filepath.Join(dir, "test.db"))
4444
log.Debug("Done.")
4545

0 commit comments

Comments
 (0)