Skip to content

Commit

Permalink
Make the test fail in reasonable time
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Jun 22, 2019
1 parent 16976a3 commit a5a2fbb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions p2p/host/eventbus/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ func TestCloseBlocking(t *testing.T) {
sub.Close() // cancel sub
}

func panicOnTimeout(d time.Duration) {
<-time.After(d)
panic("timeout reached")
}

func TestSubFailFully(t *testing.T) {
bus := NewBus()
em, err := bus.Emitter(new(EventB))
Expand All @@ -330,6 +335,8 @@ func TestSubFailFully(t *testing.T) {
t.Fatal(err)
}

go panicOnTimeout(5 * time.Second)

em.Emit(EventB(159)) // will hang if sub doesn't fail properly
}

Expand Down

0 comments on commit a5a2fbb

Please sign in to comment.