Skip to content

Commit

Permalink
💯 tests and 💯% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Zinsmeister committed Nov 1, 2018
1 parent c7c6be4 commit b978763
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
12 changes: 6 additions & 6 deletions contracts/IdentityRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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."
);
_;
}

Expand Down
19 changes: 18 additions & 1 deletion test/IdentityRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b978763

Please sign in to comment.