Skip to content

Commit

Permalink
Fix intermittent test failure (#849)
Browse files Browse the repository at this point in the history
* Fix intermittent test failure
* Improve error reporting in test that sometimes fails
  • Loading branch information
gammazero authored Feb 18, 2025
1 parent 8441fd4 commit 065e236
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bitswap/client/internal/messagequeue/messagequeue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func collectMessages(ctx context.Context,
messagesSent <-chan []bsmsg.Entry,
timeout time.Duration,
) [][]bsmsg.Entry {
t.Helper()
var messagesReceived [][]bsmsg.Entry
timeoutctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
Expand Down Expand Up @@ -317,7 +318,6 @@ func TestSendingMessagesPriority(t *testing.T) {
}

func TestCancelOverridesPendingWants(t *testing.T) {
t.Parallel()
ctx := context.Background()
messagesSent := make(chan []bsmsg.Entry)
resetChan := make(chan struct{}, 1)
Expand Down Expand Up @@ -400,7 +400,7 @@ func TestWantOverridesPendingCancels(t *testing.T) {

messages = collectMessages(ctx, t, messagesSent, collectTimeout)
if totalEntriesLength(messages) != 3 {
t.Fatal("Wrong message count", totalEntriesLength(messages))
t.Fatalf("Wrong message count, expected 3 got %d", totalEntriesLength(messages))
}

// Should send 1 want-block and 2 cancels
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/gabriel-vasile/mimetype v1.4.6
github.com/gammazero/chanqueue v1.0.0
github.com/gammazero/deque v1.0.0
github.com/gogo/protobuf v1.3.2
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -99,6 +98,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20250202011525-fc3143867406 // indirect
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect
Expand Down

0 comments on commit 065e236

Please sign in to comment.