Skip to content

Commit

Permalink
holepunch: fix flaky TestEndToEndSimConnect test (#1508)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored May 19, 2022
1 parent d3a561e commit 39fd9a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion p2p/protocol/holepunch/holepunch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,19 @@ func TestEndToEndSimConnect(t *testing.T) {
require.Equal(t, holepunch.StartHolePunchEvtT, h2Events[0].Type)
require.Equal(t, holepunch.HolePunchAttemptEvtT, h2Events[1].Type)
require.Equal(t, holepunch.EndHolePunchEvtT, h2Events[2].Type)

h1Events := h1tr.getEvents()
require.Len(t, h1Events, 2)
// We don't really expect a hole-punched connection to be established in this test,
// as we probably don't get the timing right for the TCP simultaneous open.
// From time to time, it still happens occasionally, and then we get a EndHolePunchEvtT here.
if len(h1Events) != 2 && len(h1Events) != 3 {
t.Fatal("expected either 2 or 3 events")
}
require.Equal(t, holepunch.StartHolePunchEvtT, h1Events[0].Type)
require.Equal(t, holepunch.HolePunchAttemptEvtT, h1Events[1].Type)
if len(h1Events) == 3 {
require.Equal(t, holepunch.EndHolePunchEvtT, h1Events[2].Type)
}
}

func TestFailuresOnInitiator(t *testing.T) {
Expand Down

0 comments on commit 39fd9a0

Please sign in to comment.