Skip to content

Commit

Permalink
4844 tests to dedicated contract: testCannotRegisterIdentitiesAsNonId…
Browse files Browse the repository at this point in the history
…entityOperator
  • Loading branch information
wzmuda committed Aug 22, 2024
1 parent 89ac500 commit 78b1b8f
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,37 @@ contract WorldIDIdentityManagerIdentityRegistration4844 is WorldIDIdentityManage
// Test
assertCallFailsOn(identityManagerAddress, registerCallData, expectedError);
}

/// @notice Tests that it reverts if an attempt is made to register identities as an address
/// that is not the identity operator address.
function testCannotRegisterIdentitiesAsNonIdentityOperator(address nonOperator) public {
// Setup
vm.assume(nonOperator != address(this) && nonOperator != address(0x0));

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(identityCommitments.length),
startIndex: startIndex
});

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

bytes memory errorData =
abi.encodeWithSelector(ManagerImplV1.Unauthorized.selector, nonOperator);
vm.prank(nonOperator);

// Test
assertCallFailsOn(identityManagerAddress, callData, errorData);
}
}

0 comments on commit 78b1b8f

Please sign in to comment.