From c9711c22504648f2f1a05a3476a8b6213e37b231 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 13 Mar 2018 19:30:12 -0400 Subject: [PATCH] Updated test unit to reflect changes in recovery contract --- contracts/tests/TestContract.sol | 23 +++++++++++++++++++++++ utils/identityUtils.js | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/contracts/tests/TestContract.sol b/contracts/tests/TestContract.sol index 0ed094e..3074bda 100644 --- a/contracts/tests/TestContract.sol +++ b/contracts/tests/TestContract.sol @@ -8,4 +8,27 @@ contract TestContract { function test() public { TestFunctionExecuted(); } + + + /* + Helper function to be used in unit testing due to error in web3 + web3.utils.soliditySha3([1, 2, 3]) + Error: Autodetection of array types is not supported. + at _processSoliditySha3Args (node_modules/web3-utils/src/soliditySha3.js:176:15) + */ + function hash( + address identity, + bytes32 _revealedSecret, + address _dest, + bytes _data, + bytes32 _newSecret, + bytes32[] _newFriendsHashes) + external + pure + returns(bytes32) + { + return keccak256(identity, _revealedSecret, _dest, _data, _newSecret, _newFriendsHashes); + + } + } \ No newline at end of file diff --git a/utils/identityUtils.js b/utils/identityUtils.js index 5998092..7b52d62 100644 --- a/utils/identityUtils.js +++ b/utils/identityUtils.js @@ -103,6 +103,21 @@ const _setupRecovery = function(address){ }, [address]); } +const _managerReset = function(address){ + if(!/^(0x)?[0-9a-f]{0,40}$/i.test(address)) + throw new Error('Address "'+ address +'" is not a valid Ethereum address.'); + + return web3EthAbi.encodeFunctionCall({ + name: 'managerReset', + type: 'function', + inputs: [{ + type: 'address', + name: '_newKey' + }] + }, [address]); +} + + const _updateUpdatableInstance = function(address){ if(!/^(0x)?[0-9a-f]{0,40}$/i.test(address)) throw new Error('Address "'+ address +'" is not a valid Ethereum address.'); @@ -167,6 +182,7 @@ module.exports = { removeKey: _removeKey, setMinimumApprovalsByKeyType: _setMinimumApprovalsByKeyType, setupRecovery: _setupRecovery, + managerReset: _managerReset, updateUpdatableInstance: _updateUpdatableInstance, updateRequestUpdatableInstance: _updateRequestUpdatableInstance, updateConfirmUpdatableInstance: _updateConfirmUpdatableInstance,