aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
commite0d5b9daf84cba31bbbcd2cfbe1f64623eace61a (patch)
tree84929c7ae4e95896dacfb69517aaaba97ec8ad85 /packages/contracts/test/asset_proxy
parenta97d77064aacda3de74b04894f110b05298c5ca8 (diff)
parent785b9811f30869f01242ce9ff81c282bf7f5352f (diff)
downloaddexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.gz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.bz2
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.lz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.xz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.zst
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.zip
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/improve-linting
Diffstat (limited to 'packages/contracts/test/asset_proxy')
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts17
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts33
2 files changed, 26 insertions, 24 deletions
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 5f0c7f7ff..922baa856 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -4,6 +4,7 @@ import 'make-promises-safe';
import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable';
import { artifacts } from '../../src/utils/artifacts';
+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';
@@ -42,9 +43,9 @@ describe('Authorizable', () => {
});
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should allow owner to add an authorized address', async () => {
await web3Wrapper.awaitTransactionSuccessAsync(
@@ -59,9 +60,9 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -71,11 +72,11 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: notOwner,
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should allow owner to remove an authorized address', async () => {
@@ -94,11 +95,11 @@ describe('Authorizable', () => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: owner,
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index b6284a81e..eb2a1544f 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -8,6 +8,7 @@ import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/d
import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c721_token';
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
+import { expectRevertOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
@@ -142,7 +143,7 @@ describe('Asset Transfer Proxies', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
// Perform a transfer; expect this to fail.
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -150,7 +151,7 @@ describe('Asset Transfer Proxies', () => {
transferAmount,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if requesting address is not authorized', async () => {
@@ -158,7 +159,7 @@ describe('Asset Transfer Proxies', () => {
const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -168,7 +169,7 @@ describe('Asset Transfer Proxies', () => {
from: notAuthorized,
},
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -215,7 +216,7 @@ describe('Asset Transfer Proxies', () => {
const toAddresses = _.times(numTransfers, () => takerAddress);
const amounts = _.times(numTransfers, () => amount);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc20Proxy.batchTransferFrom.sendTransactionAsync(
assetMetadata,
fromAddresses,
@@ -223,7 +224,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -272,7 +273,7 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(0);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -280,7 +281,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: exchangeAddress },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if transferring > 1 amount of a token', async () => {
@@ -294,7 +295,7 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(500);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -302,7 +303,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: exchangeAddress },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if allowances are too low', async () => {
@@ -320,7 +321,7 @@ describe('Asset Transfer Proxies', () => {
);
// Perform a transfer; expect this to fail.
const amount = new BigNumber(1);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -330,7 +331,7 @@ describe('Asset Transfer Proxies', () => {
from: notAuthorized,
},
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if requesting address is not authorized', async () => {
@@ -341,7 +342,7 @@ describe('Asset Transfer Proxies', () => {
);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -349,7 +350,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -399,7 +400,7 @@ describe('Asset Transfer Proxies', () => {
const toAddresses = _.times(numTransfers, () => takerAddress);
const amounts = _.times(numTransfers, () => new BigNumber(1));
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.batchTransferFrom.sendTransactionAsync(
assetMetadata,
fromAddresses,
@@ -407,7 +408,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});