Skip to content

Commit

Permalink
fix uninit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Aug 25, 2023
1 parent abc2da2 commit d15e456
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/test/identity-manager/WorldIDIdentityManagerTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ contract WorldIDIdentityManagerTest is WorldIDTest {
uint256 identityCommitmentsSize = 3;
uint256[8] proof;

uint32[] deletionIndices = [0, 1, 2];

// Needed for testing things.
uint256 internal constant SNARK_SCALAR_FIELD =
21888242871839275222246405745257275088548364400416034343698204186575808495617;
Expand Down
48 changes: 47 additions & 1 deletion src/test/identity-manager/WorldIDIdentityManagerUninit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ contract WorldIDIdentityManagerUninit is WorldIDIdentityManagerTest {
assertCallFailsOn(identityManagerAddress, callData, expectedError);
}

/// @notice Checks that it is impossible to call `deleteIdentities` while the contract is not
/// initialised.
function testShouldNotCallDeleteIdentitiesWhileUninit() public {
// Setup
makeUninitIdentityManager();
bytes memory callData = abi.encodeCall(
ManagerImpl.deleteIdentities,
(proof, preRoot, deletionIndices, postRoot)
);
bytes memory expectedError =
abi.encodeWithSelector(CheckInitialized.ImplementationNotInitialized.selector);

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

/// @notice Checks that it is impossible to call `updateIdentities` while the contract is not
/// initialised.
function testShouldNotCallUpdateIdentitiesWhileUninit(
Expand Down Expand Up @@ -118,7 +134,7 @@ contract WorldIDIdentityManagerUninit is WorldIDIdentityManagerTest {

/// @notice Checks that it is impossible to call `getRegisterIdentitiesVerifierLookupTableAddress`
/// while the contract is not initialized.
function testShouldNotCallgetRegisterIdentitiesVerifierLookupTableAddressWhileUninit() public {
function testShouldNotCallGetRegisterIdentitiesVerifierLookupTableAddressWhileUninit() public {
// Setup
makeUninitIdentityManager();
bytes memory callData =
Expand Down Expand Up @@ -146,6 +162,36 @@ contract WorldIDIdentityManagerUninit is WorldIDIdentityManagerTest {
assertCallFailsOn(identityManagerAddress, callData, expectedError);
}

/// @notice Checks that it is impossible to call `getDeleteIdentitiesVerifierLookupTableAddress`
/// while the contract is not initialized.
function testShouldNotCallGetDeleteIdentitiesVerifierLookupTableAddressWhileUninit() public {
// Setup
makeUninitIdentityManager();
bytes memory callData =
abi.encodeCall(ManagerImpl.getDeleteIdentitiesVerifierLookupTableAddress, ());
bytes memory expectedError =
abi.encodeWithSelector(CheckInitialized.ImplementationNotInitialized.selector);

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

/// @notice Checks that it is impossible to call `setDeleteIdentitiesVerifierLookupTable`
/// while the contract is not initialized.
function testShouldNotCallSetDeleteIdentitiesVerifierLookupTableWhileUninit() public {
// Setup
makeUninitIdentityManager();
(,VerifierLookupTable deletionVerifiers ,) = makeVerifierLookupTables(TC.makeDynArray([75]));
bytes memory callData = abi.encodeCall(
ManagerImpl.setDeleteIdentitiesVerifierLookupTable, (deletionVerifiers)
);
bytes memory expectedError =
abi.encodeWithSelector(CheckInitialized.ImplementationNotInitialized.selector);

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

/// @notice Checks that it is impossible to call `getIdentityUpdateVerifierLookupTableAddress`
/// while the contract is not initialized.
function testShouldNotCallGetIdentityUpdateVerifierLookupTableAddressWhileUninit() public {
Expand Down

0 comments on commit d15e456

Please sign in to comment.