Skip to content

Commit

Permalink
fix(deployment): anyOf ignored when allOf present (#936)
Browse files Browse the repository at this point in the history
fix copy-paste in anyOf test

Signed-off-by: Artur Troian <troian.ap@gmail.com>
  • Loading branch information
troian committed Nov 27, 2020
1 parent 116eaba commit 703711d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions x/deployment/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ func (g GroupSpec) MatchRequirements(provider []atypes.Provider) bool {
}
}

for _, validator := range g.Requirements.SignedBy.AnyOf {
if existingAttr, exists := existingRequirements[validator]; exists {
if types.AttributesSubsetOf(g.Requirements.Attributes, existingAttr) {
if len(g.Requirements.SignedBy.AnyOf) != 0 {
for _, validator := range g.Requirements.SignedBy.AnyOf {
if existingAttr, exists := existingRequirements[validator]; exists &&
types.AttributesSubsetOf(g.Requirements.Attributes, existingAttr) {
return true
}
}

return false
}

return true
Expand Down
2 changes: 1 addition & 1 deletion x/deployment/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func TestGroupPlacementRequirementsSignerAnyOf(t *testing.T) {
OrderBidDuration: types.DefaultOrderBiddingDuration,
}

group.Requirements.SignedBy.AllOf = append(group.Requirements.SignedBy.AllOf, "validator1")
group.Requirements.SignedBy.AnyOf = append(group.Requirements.SignedBy.AnyOf, "validator1")

providerAttr := []atypes.Provider{
{
Expand Down

0 comments on commit 703711d

Please sign in to comment.