Skip to content

Commit

Permalink
[Keystone] Disable remote calls to RegisterToWorkflow (#15352)
Browse files Browse the repository at this point in the history
* [Keystone] Disable remote calls to RegisterToWorkflow

* Remove failing test

---------

Co-authored-by: Cedric Cordenier <cedric.cordenier@smartcontract.com>
  • Loading branch information
bolekk and cedric-cordenier authored Nov 21, 2024
1 parent f3ae328 commit e4a2914
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 132 deletions.
30 changes: 0 additions & 30 deletions core/capabilities/remote/executable/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,10 @@ func (c *client) Info(ctx context.Context) (commoncap.CapabilityInfo, error) {
}

func (c *client) RegisterToWorkflow(ctx context.Context, registerRequest commoncap.RegisterToWorkflowRequest) error {
req, err := request.NewClientRegisterToWorkflowRequest(ctx, c.lggr, registerRequest, c.remoteCapabilityInfo, c.localDONInfo, c.dispatcher,
c.requestTimeout)

if err != nil {
return fmt.Errorf("failed to create client request: %w", err)
}

if err = c.sendRequest(req); err != nil {
return fmt.Errorf("failed to send request: %w", err)
}

resp := <-req.ResponseChan()
if resp.Err != nil {
return fmt.Errorf("error executing request: %w", resp.Err)
}
return nil
}

func (c *client) UnregisterFromWorkflow(ctx context.Context, unregisterRequest commoncap.UnregisterFromWorkflowRequest) error {
req, err := request.NewClientUnregisterFromWorkflowRequest(ctx, c.lggr, unregisterRequest, c.remoteCapabilityInfo,
c.localDONInfo, c.dispatcher, c.requestTimeout)

if err != nil {
return fmt.Errorf("failed to create client request: %w", err)
}

if err = c.sendRequest(req); err != nil {
return fmt.Errorf("failed to send request: %w", err)
}

resp := <-req.ResponseChan()
if resp.Err != nil {
return fmt.Errorf("error executing request: %w", resp.Err)
}
return nil
}

Expand Down
102 changes: 0 additions & 102 deletions core/capabilities/remote/executable/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,6 @@ import (
p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types"
)

func Test_RemoteExecutableCapability_InsufficientCapabilityResponses(t *testing.T) {
ctx := testutils.Context(t)

responseTest := func(t *testing.T, responseCh commoncap.CapabilityResponse, responseError error) {
assert.NotNil(t, responseError)
}

capability := &TestCapability{}

transmissionSchedule, err := values.NewMap(map[string]any{
"schedule": transmission.Schedule_AllAtOnce,
"deltaStage": "10ms",
})
require.NoError(t, err)

var methods []func(ctx context.Context, caller commoncap.ExecutableCapability)

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
executeCapability(ctx, t, caller, transmissionSchedule, responseTest)
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Millisecond, 10, 10, 10*time.Minute, method)
}
}

func Test_RemoteExecutableCapability_InsufficientWorkflowRequests(t *testing.T) {
ctx := testutils.Context(t)

responseTest := func(t *testing.T, responseCh commoncap.CapabilityResponse, responseError error) {
assert.NotNil(t, responseError)
}

timeOut := 10 * time.Minute

capability := &TestCapability{}

transmissionSchedule, err := values.NewMap(map[string]any{
"schedule": transmission.Schedule_AllAtOnce,
"deltaStage": "10ms",
})
require.NoError(t, err)

var methods []func(ctx context.Context, caller commoncap.ExecutableCapability)

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
executeCapability(ctx, t, caller, transmissionSchedule, responseTest)
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 10, 10*time.Millisecond, 10, 9, timeOut, method)
}
}

func Test_RemoteExecutableCapability_TransmissionSchedules(t *testing.T) {
ctx := testutils.Context(t)

Expand Down Expand Up @@ -214,18 +136,6 @@ func Test_RemoteExecutionCapability_CapabilityError(t *testing.T) {
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: failed to register to workflow: an error", responseError.Error())
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: failed to unregister from workflow: an error", responseError.Error())
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Minute, 10, 9, 10*time.Minute, method)
}
Expand All @@ -250,18 +160,6 @@ func Test_RemoteExecutableCapability_RandomCapabilityError(t *testing.T) {
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: request expired", responseError.Error())
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: request expired", responseError.Error())
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Millisecond, 10, 9, 10*time.Minute,
method)
Expand Down

0 comments on commit e4a2914

Please sign in to comment.