diff --git a/contracts/IdentityRegistry.sol b/contracts/IdentityRegistry.sol index 9846ff6..c0bc13e 100644 --- a/contracts/IdentityRegistry.sol +++ b/contracts/IdentityRegistry.sol @@ -102,12 +102,12 @@ contract IdentityRegistry is SignatureVerifier { /// @param check If true, ensures that the address has an Identity, if false, vice versa. /// @return true if the associated status is equal to check, false otherwise. modifier _hasIdentity(address _address, bool check) { - if (hasIdentity(_address) != check) { - if (check) - require(false, "The passed address does not have an identity but should."); - else - require(false, "The passed address has an identity but should not."); - } + require( + hasIdentity(_address) == check, + check ? + "The passed address does not have an identity but should." : + "The passed address has an identity but should not." + ); _; } diff --git a/test/IdentityRegistry.js b/test/IdentityRegistry.js index 7e4d76e..b34cb62 100644 --- a/test/IdentityRegistry.js +++ b/test/IdentityRegistry.js @@ -188,6 +188,21 @@ contract('Testing Identity', function (accounts) { }) }) + it('Identity created FAIL -- has an address', async function () { + await instances.IdentityRegistry.createIdentity( + identity.recoveryAddress.address, identity.providers[0].address, [], + { from: identity.associatedAddresses[0].address } + ) + .then(() => assert.fail('got an EIN', 'transaction should fail')) + .catch(error => { + if (error.message !== defaultErrorMessage) { + assert.include( + error.message, 'The passed address has an identity but should not.', 'wrong rejection reason' + ) + } + }) + }) + it('provider can add other addresses FAIL -- not a provider', async function () { for (const address of [identity.associatedAddresses[1], identity.associatedAddresses[2], accountsPrivate[5]]) { const timestamp = Math.round(new Date() / 1000) - 1 @@ -350,8 +365,10 @@ contract('Testing Identity', function (accounts) { )) } } + }) - // clean up by removing address + it('provider can add other addresses -- FAIL too many cleaning up', async function () { + const maxAddresses = await instances.IdentityRegistry.maxAssociatedAddresses.call() for (let i = 0; i < maxAddresses - 1; i++) { const timestamp = Math.round(new Date() / 1000) - 1 const permissionString = web3.utils.soliditySha3(