Skip to content

Commit

Permalink
add scoping to avoid breaking test into multiple parts
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Sep 7, 2023
1 parent e838de6 commit 636f818
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ contract WorldIDIdentityManagerIdentityDeletion is WorldIDIdentityManagerTest {
uint256[8] memory actualProof = prepareDeleteIdentitiesTestCase(prf);
bytes memory callData = abi.encodeCall(
ManagerImpl.deleteIdentities,
(actualProof, uint32(packedDeletionIndices.length * 8), packedDeletionIndices, newPreRoot, newPostRoot)
(
actualProof,
uint32(packedDeletionIndices.length * 8),
packedDeletionIndices,
newPreRoot,
newPostRoot
)
);

bytes memory setupCallData =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,43 +359,33 @@ contract WorldIDIdentityManagerIdentityUpdate is WorldIDIdentityManagerTest {
uint256[] memory newIdents,
uint256[8] memory actualProof
) = prepareUpdateIdentitiesTestCase(identities, prf);
(
VerifierLookupTable insertVerifiers,
VerifierLookupTable deletionVerifiers,
VerifierLookupTable updateVerifiers
) = makeVerifierLookupTables(TC.makeDynArray([identities.length]));
makeNewIdentityManager(
treeDepth,
newPreRoot,
insertVerifiers,
deletionVerifiers,
updateVerifiers,
semaphoreVerifier
);
// scoping to avoid stack too deep errors
{
(
VerifierLookupTable insertVerifiers,
VerifierLookupTable deletionVerifiers,
VerifierLookupTable updateVerifiers
) = makeVerifierLookupTables(TC.makeDynArray([identities.length]));
makeNewIdentityManager(
treeDepth,
newPreRoot,
insertVerifiers,
deletionVerifiers,
updateVerifiers,
semaphoreVerifier
);
}

if (changeOld) {
oldIdents[position] = SNARK_SCALAR_FIELD + i;
} else {
newIdents[position] = SNARK_SCALAR_FIELD + i;
}

// breaking up into two due to stack too deep error
testCannotRegisterIdentitiesWithUnreducedIdentitiesPart2(
i, newPreRoot, actualProof, oldIdents, newIdents, leafIndices
);
}

function testCannotRegisterIdentitiesWithUnreducedIdentitiesPart2(
uint128 i,
uint128 newPreRoot,
uint256[8] memory actualProof,
uint256[] memory oldIdents,
uint256[] memory newIdents,
uint32[] memory leafIndices
) internal {
bytes memory callData = abi.encodeCall(
ManagerImpl.updateIdentities,
(actualProof, newPreRoot, leafIndices, oldIdents, newIdents, insertionPostRoot)
);

bytes memory expectedError = abi.encodeWithSelector(
ManagerImpl.UnreducedElement.selector,
ManagerImpl.UnreducedElementType.IdentityCommitment,
Expand Down

0 comments on commit 636f818

Please sign in to comment.