Skip to content

Commit

Permalink
Test SafeSubscription concurrent unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
emlautarom1 committed May 31, 2024
1 parent 7a1bc30 commit 6f0b117
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/safeclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,21 @@ func TestSubscribeFilterLogs_ErrorInSubscription_Resubscribe(t *testing.T) {

triggerError()
}

func TestSafeSubscription_ConcurrentUnsubscribe(t *testing.T) {
mockCtrl := gomock.NewController(t)
sub := mocks.NewMockSubscription(mockCtrl)
sub.EXPECT().Unsubscribe().Times(1)

safeSub := safeclient.NewSafeSubscription(sub)

var wg sync.WaitGroup
for i := 1; i <= 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
safeSub.Unsubscribe()
}()
}
wg.Wait()
}

0 comments on commit 6f0b117

Please sign in to comment.