Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/aptos-init-mock-trigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"chainlink": patch
---

#internal
Forward-port the Aptos mock streams trigger compatibility path onto `develop` behind explicit local capability opt-in.
29 changes: 20 additions & 9 deletions core/capabilities/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,36 @@ func NewRegistry(lggr logger.Logger) *Registry {
// interface. It is used when ExternalCapabilitiesRegistry is not available.
type TestMetadataRegistry struct {
core.UnimplementedCapabilitiesRegistryMetadata
// WorkflowDONF allows local CRE to override the synthetic workflow DON fault
// tolerance for compatibility paths that still expect a multi-signer shape.
WorkflowDONF uint8
}

const (
testWorkflowDONID = 1
testWorkflowDONConfigVersion = 1
)

func (t *TestMetadataRegistry) LocalNode(ctx context.Context) (capabilities.Node, error) {
peerID := p2ptypes.PeerID{}
workflowDON := capabilities.DON{
ID: 1,
ConfigVersion: 1,
return capabilities.Node{
PeerID: &peerID,
WorkflowDON: newTestWorkflowDON(peerID, t.WorkflowDONF),
CapabilityDONs: []capabilities.DON{},
}, nil
}

func newTestWorkflowDON(peerID p2ptypes.PeerID, faultTolerance uint8) capabilities.DON {
return capabilities.DON{
ID: testWorkflowDONID,
ConfigVersion: testWorkflowDONConfigVersion,
Members: []p2ptypes.PeerID{
peerID,
},
F: 0,
F: faultTolerance,
IsPublic: false,
AcceptsWorkflows: true,
}
return capabilities.Node{
PeerID: &peerID,
WorkflowDON: workflowDON,
CapabilityDONs: []capabilities.DON{},
}, nil
}

func (t *TestMetadataRegistry) NodeByPeerID(ctx context.Context, _ p2ptypes.PeerID) (capabilities.Node, error) {
Expand Down
39 changes: 39 additions & 0 deletions core/capabilities/registry_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package capabilities

import (
"context"
"testing"

"github.com/stretchr/testify/require"
)

func TestTestMetadataRegistry_LocalNode_UsesConfiguredWorkflowDONF(t *testing.T) {
t.Parallel()

tests := []struct {
name string
registry TestMetadataRegistry
expectedDonF uint8
}{
{
name: "default workflow DON fault tolerance",
registry: TestMetadataRegistry{},
expectedDonF: 0,
},
{
name: "mock trigger workflow DON fault tolerance",
registry: TestMetadataRegistry{WorkflowDONF: 1},
expectedDonF: 1,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

node, err := tt.registry.LocalNode(context.Background())
require.NoError(t, err)
require.Equal(t, tt.expectedDonF, node.WorkflowDON.F)
})
}
}
Loading
Loading