diff --git a/src/test/identity-manager/WorldIDIdentityManagerIdentityRegistration4844.t.sol b/src/test/identity-manager/WorldIDIdentityManagerIdentityRegistration4844.t.sol index 5732e35..33d0ce1 100644 --- a/src/test/identity-manager/WorldIDIdentityManagerIdentityRegistration4844.t.sol +++ b/src/test/identity-manager/WorldIDIdentityManagerIdentityRegistration4844.t.sol @@ -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); + } }