Skip to content

Commit

Permalink
remove one and only one check
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd committed Jul 2, 2024
1 parent dfb3da4 commit a4ec0e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 0 additions & 7 deletions core/services/ccipcapability/launcher/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,15 @@ func filterCCIPDONs(
) (map[registrysyncer.DonID]kcr.CapabilitiesRegistryDONInfo, error) {
ccipDONs := make(map[registrysyncer.DonID]kcr.CapabilitiesRegistryDONInfo)
for _, don := range state.IDsToDONs {
// CCIP DONs should only have one capability, CCIP.
var found bool
for _, donCapabilities := range don.CapabilityConfigurations {
hid, err := hashedCapabilityId(ccipCapability.LabelledName, ccipCapability.Version)
if err != nil {
return nil, fmt.Errorf("failed to hash capability id: %w", err)
}
if donCapabilities.CapabilityId == hid {
ccipDONs[registrysyncer.DonID(don.Id)] = don
found = true
}
}
if found && len(don.CapabilityConfigurations) > 1 {
return nil, fmt.Errorf("found more than one capability (actual: %d) in the CCIP DON %d",
len(don.CapabilityConfigurations), don.Id)
}
}

return ccipDONs, nil
Expand Down
16 changes: 14 additions & 2 deletions core/services/ccipcapability/launcher/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,20 @@ func Test_filterCCIPDONs(t *testing.T) {
},
},
},
map[registrysyncer.DonID]kcr.CapabilitiesRegistryDONInfo{},
true,
map[registrysyncer.DonID]kcr.CapabilitiesRegistryDONInfo{
1: {
Id: 1,
CapabilityConfigurations: []kcr.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: mustHashedCapabilityId("ccip", "v1.0.0"),
},
{
CapabilityId: mustHashedCapabilityId("ccip", "v1.1.0"),
},
},
},
},
false,
},
}
for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion core/services/ccipcapability/launcher/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func TestIntegration_Launcher(t *testing.T) {
)

gomega.NewWithT(t).Eventually(func() bool {
return len(launcher.runningDONs()) == 1
return len(launcher.runningDONIDs()) == 1
}, testutils.WaitTimeout(t), testutils.TestInterval).Should(gomega.BeTrue())
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/ccipcapability/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (l *launcher) getLatestState() registrysyncer.State {
return l.latestState
}

func (l *launcher) runningDONs() []registrysyncer.DonID {
func (l *launcher) runningDONIDs() []registrysyncer.DonID {
l.lock.RLock()
defer l.lock.RUnlock()
var runningDONs []registrysyncer.DonID
Expand Down

0 comments on commit a4ec0e0

Please sign in to comment.