diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-09-01 06:59:03 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-09-04 22:57:47 +0800 |
commit | 3f1586045c61024d03a338a7d464e77d9af526b2 (patch) | |
tree | f3a95c9b22c7e3605b91f81b4eabb01409a32e2a /packages/contracts/test | |
parent | ada5563b1fd2024ef310786eb8b1f32f3ecee4f0 (diff) | |
download | dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar.gz dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar.bz2 dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar.lz dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar.xz dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.tar.zst dexon-sol-tools-3f1586045c61024d03a338a7d464e77d9af526b2.zip |
Add test for executeRemoveAuthorizedAddressAtIndex when called by non-owner
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/multisig/asset_proxy_owner.ts | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/packages/contracts/test/multisig/asset_proxy_owner.ts b/packages/contracts/test/multisig/asset_proxy_owner.ts index bb2b3b1a3..f8d66118a 100644 --- a/packages/contracts/test/multisig/asset_proxy_owner.ts +++ b/packages/contracts/test/multisig/asset_proxy_owner.ts @@ -34,6 +34,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('AssetProxyOwner', () => { let owners: string[]; let authorized: string; + let notOwner: string; const REQUIRED_APPROVALS = new BigNumber(2); const SECONDS_TIME_LOCKED = new BigNumber(1000000); @@ -51,7 +52,9 @@ describe('AssetProxyOwner', () => { before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owners = [accounts[0], accounts[1]]; - const initialOwner = (authorized = accounts[0]); + authorized = accounts[2]; + notOwner = accounts[3]; + const initialOwner = accounts[0]; erc20Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync( artifacts.MixinAuthorizable, provider, @@ -395,7 +398,10 @@ describe('AssetProxyOwner', () => { ); }); - it('should execute removeAuthorizedAddressAtIndex for registered address if fully confirmed', async () => { + it('should execute removeAuthorizedAddressAtIndex for registered address if fully confirmed and called by owner', async () => { + const isAuthorizedBefore = await erc20Proxy.authorized.callAsync(authorized); + expect(isAuthorizedBefore).to.equal(true); + const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( authorized, erc20Index, @@ -418,8 +424,38 @@ describe('AssetProxyOwner', () => { const isExecuted = tx[3]; expect(isExecuted).to.equal(true); - const isAuthorized = await erc20Proxy.authorized.callAsync(authorized); - expect(isAuthorized).to.equal(false); + const isAuthorizedAfter = await erc20Proxy.authorized.callAsync(authorized); + expect(isAuthorizedAfter).to.equal(false); + }); + + it('should execute removeAuthorizedAddressAtIndex for registered address if fully confirmed and called by non-owner', async () => { + const isAuthorizedBefore = await erc20Proxy.authorized.callAsync(authorized); + expect(isAuthorizedBefore).to.equal(true); + + const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( + authorized, + erc20Index, + ); + const submitRes = await multiSigWrapper.submitTransactionAsync( + erc20Proxy.address, + removeAuthorizedAddressAtIndexData, + owners[0], + ); + const submitLog = submitRes.logs[0] as LogWithDecodedArgs<AssetProxyOwnerSubmissionEventArgs>; + const txId = submitLog.args.transactionId; + + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + + const execRes = await multiSigWrapper.executeRemoveAuthorizedAddressAtIndexAsync(txId, notOwner); + const execLog = execRes.logs[1] as LogWithDecodedArgs<AssetProxyOwnerExecutionEventArgs>; + expect(execLog.args.transactionId).to.be.bignumber.equal(txId); + + const tx = await testAssetProxyOwner.transactions.callAsync(txId); + const isExecuted = tx[3]; + expect(isExecuted).to.equal(true); + + const isAuthorizedAfter = await erc20Proxy.authorized.callAsync(authorized); + expect(isAuthorizedAfter).to.equal(false); }); it('should throw if already executed', async () => { |