-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Check if DefaultConfig is nil before merging (#13988)
- Loading branch information
1 parent
1b4cb83
commit 0e8f2de
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ func (t testConfigProvider) ConfigForCapability(ctx context.Context, capabilityI | |
return t.configForCapability(ctx, capabilityID, donID) | ||
} | ||
|
||
return capabilities.CapabilityConfiguration{DefaultConfig: values.EmptyMap()}, nil | ||
return capabilities.CapabilityConfiguration{}, nil | ||
} | ||
|
||
// newTestEngine creates a new engine with some test defaults. | ||
|
@@ -1063,3 +1063,54 @@ func TestEngine_MergesWorkflowConfigAndCRConfig(t *testing.T) { | |
assert.Equal(t, m.(map[string]any)["deltaStage"], "1s") | ||
assert.Equal(t, m.(map[string]any)["schedule"], "allAtOnce") | ||
} | ||
|
||
func TestEngine_HandlesNilConfigOnchain(t *testing.T) { | ||
ctx := testutils.Context(t) | ||
reg := coreCap.NewRegistry(logger.TestLogger(t)) | ||
|
||
trigger, _ := mockTrigger(t) | ||
|
||
require.NoError(t, reg.Add(ctx, trigger)) | ||
require.NoError(t, reg.Add(ctx, mockConsensus())) | ||
writeID := "[email protected]" | ||
|
||
gotConfig := values.EmptyMap() | ||
target := newMockCapability( | ||
// Create a remote capability so we don't use the local transmission protocol. | ||
capabilities.MustNewRemoteCapabilityInfo( | ||
writeID, | ||
capabilities.CapabilityTypeTarget, | ||
"a write capability targeting polygon testnet", | ||
&capabilities.DON{ID: 1}, | ||
), | ||
func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { | ||
gotConfig = req.Config | ||
|
||
return capabilities.CapabilityResponse{ | ||
Value: req.Inputs, | ||
}, nil | ||
}, | ||
) | ||
require.NoError(t, reg.Add(ctx, target)) | ||
|
||
eng, testHooks := newTestEngine( | ||
t, | ||
reg, | ||
simpleWorkflow, | ||
) | ||
reg.SetLocalRegistry(testConfigProvider{}) | ||
|
||
servicetest.Run(t, eng) | ||
|
||
eid := getExecutionId(t, eng, testHooks) | ||
|
||
state, err := eng.executionStates.Get(ctx, eid) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, state.Status, store.StatusCompleted) | ||
|
||
m, err := values.Unwrap(gotConfig) | ||
require.NoError(t, err) | ||
// The write target config contains three keys | ||
assert.Len(t, m.(map[string]any), 3) | ||
} |