Add test for executeRemoveAuthorizedAddressAtIndex when called by non-owner

This commit is contained in:
Amir Bandeali 2018-08-31 15:59:03 -07:00
parent ada5563b1f
commit 3f1586045c

View File

@ -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 () => {