Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Added isOwner and isRecovery functions to IdentityManager
Browse files Browse the repository at this point in the history
  • Loading branch information
oed committed Jul 21, 2017
1 parent 6010aca commit 0f15d2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/IdentityManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,12 @@ contract IdentityManager {
t := eq(a, and(mask, calldataload(4)))
}
}

function isOwner(address identity, address owner) constant returns (bool) {
return owners[identity][owner] != 0;
}

function isRecovery(address identity, address recoveryKey) constant returns (bool) {
return recoveryKeys[identity] == recoveryKey;
}
}
8 changes: 8 additions & 0 deletions test/identityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ contract('IdentityManager', (accounts) => {
})

it('owner can add other owner', async function() {
let isOwner = await identityManager.isOwner(proxy.address, user5, {from: user1})
assert.isFalse(isOwner, 'user5 should not be owner yet')
let tx = await identityManager.addOwner(user1, proxy.address, user5, {from: user1})
let log = tx.logs[0]
assert.equal(log.event, 'OwnerAdded', 'should trigger correct event')
Expand All @@ -161,6 +163,8 @@ contract('IdentityManager', (accounts) => {
assert.equal(log.args.instigator,
user1,
'Instigator key is set in event')
isOwner = await identityManager.isOwner(proxy.address, user5, {from: user1})
assert.isTrue(isOwner, 'user5 should be owner now')
})

it('owner is rateLimited on some functions', async function() {
Expand Down Expand Up @@ -328,6 +332,8 @@ contract('IdentityManager', (accounts) => {
})

it('can change recoveryKey', async function() {
let isRecovery = await identityManager.isRecovery(proxy.address, recoveryKey2, {from: user1})
assert.isFalse(isRecovery, 'recoveryKey2 should not be recovery yet')
let tx = await identityManager.changeRecovery(user2, proxy.address, recoveryKey2, {from: user2})
const log = tx.logs[0]
assert.equal(log.args.recoveryKey,
Expand All @@ -336,6 +342,8 @@ contract('IdentityManager', (accounts) => {
assert.equal(log.args.instigator,
user2,
'Instigator key is set in event')
isRecovery = await identityManager.isRecovery(proxy.address, recoveryKey2, {from: user1})
assert.isTrue(isRecovery, 'recoveryKey2 should be recovery now')
})
})
})
Expand Down

0 comments on commit 0f15d2c

Please sign in to comment.