Skip to content

Commit 9cc32f0

Browse files
committed
Fix test race condition
1 parent d38887e commit 9cc32f0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cache/signature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func NewSignatureCache(ctx context.Context, c comm.Communication, sigChn chan in
3131
comm: c,
3232
}
3333

34-
go cache.Start()
3534
go sc.watch(ctx, sigChn)
35+
go cache.Start()
3636
return sc
3737
}
3838

cache/signature_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestRunSignatureCacheTestSuite(t *testing.T) {
3131
func (s *SignatureCacheTestSuite) SetupTest() {
3232
ctrl := gomock.NewController(s.T())
3333

34-
s.sigChn = make(chan interface{})
34+
s.sigChn = make(chan interface{}, 1)
3535

3636
s.mockCommunication = mock_communication.NewMockCommunication(ctrl)
3737
s.mockCommunication.EXPECT().Subscribe(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(sessionID string, msgType comm.MessageType, channel chan *comm.WrappedMessage) comm.SubscriptionID {
@@ -44,6 +44,7 @@ func (s *SignatureCacheTestSuite) SetupTest() {
4444
s.cancel = cancel
4545

4646
s.sc = cache.NewSignatureCache(ctx, s.mockCommunication, s.sigChn)
47+
time.Sleep(time.Millisecond * 100)
4748
}
4849
func (s *SignatureCacheTestSuite) TearDownTest() {
4950
s.cancel()
@@ -78,6 +79,7 @@ func (s *SignatureCacheTestSuite) Test_Signature_ValidMessage() {
7879
wMsg := &comm.WrappedMessage{
7980
Payload: wMsgBytes,
8081
}
82+
8183
s.msgChn <- wMsg
8284
time.Sleep(time.Millisecond * 100)
8385

0 commit comments

Comments
 (0)