Skip to content

Commit

Permalink
Merge pull request onflow#6862 from The-K-R-O-K/AndriiDiachuk/TestMes…
Browse files Browse the repository at this point in the history
…sageIndexTransactionStatusesProviderResponse_HappyPath-fix-flaky-test

TestMessageIndexTransactionStatusesProviderResponse_HappyPath test being flaky.
  • Loading branch information
AndriiDiachuk authored Jan 9, 2025
2 parents 98e7b14 + 8644455 commit c6a1f97
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strconv"
"testing"
"time"

"github.com/rs/zerolog"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -223,7 +224,7 @@ func (s *TransactionStatusesProviderSuite) TestMessageIndexTransactionStatusesPr
// Create a mock subscription and mock the channel
sub := ssmock.NewSubscription(s.T())
sub.On("Channel").Return((<-chan interface{})(txStatusesChan))
sub.On("Err").Return(nil)
sub.On("Err").Return(nil).Once()

s.api.On(
"SubscribeTransactionStatusesFromStartBlockID",
Expand Down Expand Up @@ -255,7 +256,9 @@ func (s *TransactionStatusesProviderSuite) TestMessageIndexTransactionStatusesPr
defer provider.Close()

// Run the provider in a separate goroutine to simulate subscription processing
done := make(chan struct{})
go func() {
defer close(done)
err = provider.Run()
s.Require().NoError(err)
}()
Expand All @@ -282,6 +285,9 @@ func (s *TransactionStatusesProviderSuite) TestMessageIndexTransactionStatusesPr
responses = append(responses, txStatusesRes)
}

// Wait for the provider goroutine to finish
unittest.RequireCloseBefore(s.T(), done, time.Second, "provider failed to stop")

// Verifying that indices are starting from 0
s.Require().Equal(uint64(0), responses[0].MessageIndex, "Expected MessageIndex to start with 0")

Expand Down

0 comments on commit c6a1f97

Please sign in to comment.