Skip to content

Commit f8a937f

Browse files
committed
fix: 🐛 error in complexity if there are no default claim issuer
1 parent a9a846d commit f8a937f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/api/procedures/__tests__/utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,23 @@ describe('assertRequirementsNotTooComplex', () => {
646646
mockContext
647647
)
648648
).toThrow('Compliance Requirement complexity limit exceeded');
649+
650+
expect(() =>
651+
assertRequirementsNotTooComplex(
652+
[
653+
{
654+
type: ConditionType.IsPresent,
655+
target: ConditionTarget.Both,
656+
},
657+
{
658+
type: ConditionType.IsAbsent,
659+
target: ConditionTarget.Receiver,
660+
},
661+
] as Condition[],
662+
new BigNumber(0),
663+
mockContext
664+
)
665+
).toThrow('Compliance Requirement complexity limit exceeded');
649666
});
650667

651668
it('should not throw an error if the complexity is less than the max condition complexity', async () => {

src/api/procedures/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ export function assertRequirementsNotTooComplex(
335335
conditionComplexitySum = conditionComplexitySum.multipliedBy(2);
336336
}
337337

338-
const claimIssuerLength = trustedClaimIssuers.length || defaultClaimIssuerLength;
338+
// if there are no specific trusted claim issuers or default, 1 must be used for calculation
339+
const claimIssuerLength =
340+
trustedClaimIssuers.length || defaultClaimIssuerLength.toNumber() || 1;
339341
conditionComplexitySum = conditionComplexitySum.multipliedBy(claimIssuerLength);
340342

341343
complexitySum = complexitySum.plus(conditionComplexitySum);

0 commit comments

Comments
 (0)