From b978763313cfb0fd6148a7d11d01f8955fabd292 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Thu, 1 Nov 2018 15:11:40 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AF=20tests=20and=20=F0=9F=92=AF%=20co?= =?UTF-8?q?verage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/IdentityRegistry.sol | 12 ++++++------ test/IdentityRegistry.js | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) 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(