Skip to content

Commit

Permalink
ks-409 fix the mock trigger to ensure events are sent (#14047)
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec authored Aug 6, 2024
1 parent 1d81278 commit d963b0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-hats-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal fix the mock trigger to ensure events are sent
18 changes: 10 additions & 8 deletions core/capabilities/integration_tests/mock_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,20 @@ func (s *streamsTrigger) RegisterTrigger(ctx context.Context, request capabiliti

responseCh := make(chan capabilities.CapabilityResponse)

ctxWithCancel, cancel := context.WithCancel(ctx)
ctxWithCancel, cancel := context.WithCancel(context.Background())
s.cancel = cancel
s.wg.Add(1)
go func() {
defer s.wg.Done()
select {
case <-s.stopCh:
return
case <-ctxWithCancel.Done():
return
case resp := <-s.toSend:
responseCh <- resp
for {
select {
case <-s.stopCh:
return
case <-ctxWithCancel.Done():
return
case resp := <-s.toSend:
responseCh <- resp
}
}
}()

Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/integration_tests/streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Test_AllAtOnceTransmissionSchedule(t *testing.T) {
// in the setupCapabilitiesRegistryContract function, should this order change the don IDs will need updating.
workflowDonInfo := createDonInfo(t, don{id: 1, numNodes: 7, f: 2})
triggerDonInfo := createDonInfo(t, don{id: 2, numNodes: 7, f: 2})
targetDonInfo := createDonInfo(t, don{id: 3, numNodes: 4, f: 2})
targetDonInfo := createDonInfo(t, don{id: 3, numNodes: 4, f: 1})

consumer, feedIDs, triggerSink := setupStreamDonsWithTransmissionSchedule(ctx, t, workflowDonInfo, triggerDonInfo, targetDonInfo, 3,
"2s", "allAtOnce")
Expand All @@ -45,8 +45,8 @@ func Test_OneAtATimeTransmissionSchedule(t *testing.T) {

// The don IDs set in the below calls are inferred from the order in which the dons are added to the capabilities registry
// in the setupCapabilitiesRegistryContract function, should this order change the don IDs will need updating.
workflowDonInfo := createDonInfo(t, don{id: 1, numNodes: 5, f: 1})
triggerDonInfo := createDonInfo(t, don{id: 2, numNodes: 7, f: 1})
workflowDonInfo := createDonInfo(t, don{id: 1, numNodes: 7, f: 2})
triggerDonInfo := createDonInfo(t, don{id: 2, numNodes: 7, f: 2})
targetDonInfo := createDonInfo(t, don{id: 3, numNodes: 4, f: 1})

consumer, feedIDs, triggerSink := setupStreamDonsWithTransmissionSchedule(ctx, t, workflowDonInfo, triggerDonInfo, targetDonInfo, 3,
Expand Down

0 comments on commit d963b0a

Please sign in to comment.