Skip to content

Commit

Permalink
4844 tests to dedicated contract: testCannotRegisterIdentitiesIfIdent…
Browse files Browse the repository at this point in the history
…itiesIncorrect
  • Loading branch information
wzmuda committed Aug 22, 2024
1 parent 9dece4c commit 9a359ca
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,56 @@ contract WorldIDIdentityManagerIdentityRegistration4844 is WorldIDIdentityManage
// Test
assertCallFailsOn(identityManagerAddress, registerCallData, expectedError);
}

/// @notice Checks that it reverts if the provided set of identities is incorrect.
function testCannotRegisterIdentitiesIfIdentitiesIncorrect(uint256 identity) public {
// Setup
uint256 invalidSlot = rotateSlot();
vm.assume(
identity != identityCommitments[invalidSlot] && identity < SNARK_SCALAR_FIELD
&& identity != 0x0
);
uint256[] memory identities = cloneArray(identityCommitments);
identities[invalidSlot] = identity;
ITreeVerifier actualVerifier = new TreeVerifier();
(
VerifierLookupTable insertVerifiers,
VerifierLookupTable deletionVerifiers,
VerifierLookupTable updateVerifiers
) = makeVerifierLookupTables(TC.makeDynArray([70]));
insertVerifiers.addVerifier(identityCommitmentsSize, actualVerifier);
makeNewIdentityManager(
treeDepth,
insertionPreRoot,
insertVerifiers,
deletionVerifiers,
updateVerifiers,
semaphoreVerifier
);

ManagerImplV3.RegisterIdentities4844Params memory params = ManagerImplV3.RegisterIdentities4844Params({
insertionProof: insertionProof,
commitments: commitments,
commitmentPok: commitmentsPok,
kzgCommitment: kzgCommitment,
kzgProof: kzgProof,
expectedEvaluation: insertionExpectedEvaluation,
preRoot: insertionPreRoot,
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 registerCallData = abi.encodeCall(ManagerImplV3.registerIdentities, params);

bytes memory expectedError =
abi.encodeWithSelector(ManagerImplV1.ProofValidationFailure.selector);

// Test
assertCallFailsOn(identityManagerAddress, registerCallData, expectedError);
}
}

0 comments on commit 9a359ca

Please sign in to comment.