From 1cc9d9c0713a56b59717498fcae6dc2720ca4fb0 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 22 May 2018 12:47:37 -0700 Subject: Replace constant.REVERT test assertions with expectRevertOrAlwaysFailingTransaction --- packages/contracts/test/asset_proxy/authorizable.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'packages/contracts/test/asset_proxy/authorizable.ts') diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts index e8274acb1..b09125284 100644 --- a/packages/contracts/test/asset_proxy/authorizable.ts +++ b/packages/contracts/test/asset_proxy/authorizable.ts @@ -6,6 +6,7 @@ import * as Web3 from 'web3'; import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable'; import { artifacts } from '../../src/utils/artifacts'; +import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions'; import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; @@ -44,9 +45,9 @@ describe('Authorizable', () => { }); describe('addAuthorizedAddress', () => { it('should throw if not called by owner', async () => { - return expect( + return expectRevertOrAlwaysFailingTransaction( authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }), - ).to.be.rejectedWith(constants.REVERT); + ); }); it('should allow owner to add an authorized address', async () => { await web3Wrapper.awaitTransactionSuccessAsync( @@ -61,9 +62,9 @@ describe('Authorizable', () => { await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - return expect( + return expectRevertOrAlwaysFailingTransaction( authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), - ).to.be.rejectedWith(constants.REVERT); + ); }); }); @@ -73,11 +74,11 @@ describe('Authorizable', () => { await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - return expect( + return expectRevertOrAlwaysFailingTransaction( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner, }), - ).to.be.rejectedWith(constants.REVERT); + ); }); it('should allow owner to remove an authorized address', async () => { @@ -96,11 +97,11 @@ describe('Authorizable', () => { }); it('should throw if owner attempts to remove an address that is not authorized', async () => { - return expect( + return expectRevertOrAlwaysFailingTransaction( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: owner, }), - ).to.be.rejectedWith(constants.REVERT); + ); }); }); -- cgit From 167a38e27d09af12af6c59f1b486c835420fbac1 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 5 Jun 2018 16:56:16 -0700 Subject: Add Async suffix to relevant assertions --- packages/contracts/test/asset_proxy/authorizable.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/contracts/test/asset_proxy/authorizable.ts') diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts index b09125284..945208d82 100644 --- a/packages/contracts/test/asset_proxy/authorizable.ts +++ b/packages/contracts/test/asset_proxy/authorizable.ts @@ -6,7 +6,7 @@ import * as Web3 from 'web3'; import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable'; import { artifacts } from '../../src/utils/artifacts'; -import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions'; +import { expectRevertOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions'; import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; @@ -45,7 +45,7 @@ describe('Authorizable', () => { }); describe('addAuthorizedAddress', () => { it('should throw if not called by owner', async () => { - return expectRevertOrAlwaysFailingTransaction( + return expectRevertOrAlwaysFailingTransactionAsync( authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }), ); }); @@ -62,7 +62,7 @@ describe('Authorizable', () => { await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - return expectRevertOrAlwaysFailingTransaction( + return expectRevertOrAlwaysFailingTransactionAsync( authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), ); }); @@ -74,7 +74,7 @@ describe('Authorizable', () => { await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), constants.AWAIT_TRANSACTION_MINED_MS, ); - return expectRevertOrAlwaysFailingTransaction( + return expectRevertOrAlwaysFailingTransactionAsync( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner, }), @@ -97,7 +97,7 @@ describe('Authorizable', () => { }); it('should throw if owner attempts to remove an address that is not authorized', async () => { - return expectRevertOrAlwaysFailingTransaction( + return expectRevertOrAlwaysFailingTransactionAsync( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: owner, }), -- cgit