Skip to content

Commit

Permalink
4844 tests to dedicated contract: testRegisterIdentitiesWithRunsOfZeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
wzmuda committed Aug 22, 2024
1 parent 21fafe7 commit 6128e2f
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,57 @@ contract WorldIDIdentityManagerIdentityRegistration4844 is WorldIDIdentityManage
// Test
assertCallFailsOn(identityManagerAddress, callData, expectedError);
}

/// @notice Tests that runs of zeroes are accepted by the `registerIdentities` function as valid
/// arrays of identity commitments.
function testRegisterIdentitiesWithRunsOfZeroes(uint8 identitiesLength, uint8 zeroPosition)
public
{
// Setup
vm.assume(identitiesLength != 0 && identitiesLength <= 1000);
vm.assume(zeroPosition < identitiesLength && zeroPosition > 0);
uint256[] memory identities = new uint256[](identitiesLength);
(
VerifierLookupTable insertVerifiers,
VerifierLookupTable deletionVerifiers,
VerifierLookupTable updateVerifiers
) = makeVerifierLookupTables(TC.makeDynArray([identitiesLength]));
makeNewIdentityManager(
treeDepth,
initialRoot,
insertVerifiers,
deletionVerifiers,
updateVerifiers,
semaphoreVerifier
);

for (uint256 i = 0; i < zeroPosition; ++i) {
identities[i] = i + 1;
}
for (uint256 i = zeroPosition; i < identitiesLength; ++i) {
identities[i] = 0x0;
}

ManagerImplV3.RegisterIdentities4844Params memory params = ManagerImplV3.RegisterIdentities4844Params({
insertionProof: [uint256(2), 1, 3, 4, 5, 6, 7, 9],
commitments: commitments,
commitmentPok: commitmentsPok,
kzgCommitment: kzgCommitment,
kzgProof: kzgProof,
expectedEvaluation: insertionExpectedEvaluation,
preRoot: initialRoot,
postRoot: insertionPostRoot,
kzgChallenge: kzgChallenge,
inputHash: insertionInputHash4844,
batchSize: uint32(identities.length),
startIndex: startIndex
});

// Mock blobhash. This is valid for the next call only.
prepareBlobhash(kzgToVersionedHash(kzgCommitment));
bytes memory callData = abi.encodeCall(ManagerImplV3.registerIdentities, params);

// Test
assertCallSucceedsOn(identityManagerAddress, callData, new bytes(0));
}
}

0 comments on commit 6128e2f

Please sign in to comment.