aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-07 18:27:03 +0800
committerFabio Berger <me@fabioberger.com>2018-06-07 18:27:03 +0800
commit73429fc7202ff7b58eb64a7e0b939b971f16a27e (patch)
tree6abd050f91750c819e98045d21cd8952a0e14071 /packages/contracts/test/asset_proxy
parentcb754ee1253622974e751e4a8d723a424250c878 (diff)
parente0bc01eea1c20e0afda296f331c6a475e062b59c (diff)
downloaddexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar.gz
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar.bz2
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar.lz
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar.xz
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.tar.zst
dexon-sol-tools-73429fc7202ff7b58eb64a7e0b939b971f16a27e.zip
merge v2-prototype
Diffstat (limited to 'packages/contracts/test/asset_proxy')
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts21
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts46
2 files changed, 31 insertions, 36 deletions
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 6ceebf089..347d060d6 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -1,11 +1,10 @@
-import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
import * as chai from 'chai';
import 'make-promises-safe';
-import * as Web3 from 'web3';
import { MixinAuthorizableContract } from '../../src/generated_contract_wrappers/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';
@@ -44,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(
@@ -61,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);
+ );
});
});
@@ -73,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 () => {
@@ -96,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 39dfb9938..bf2aa8f70 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,15 +1,14 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils } from '@0xproject/order-utils';
-import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
-import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c721_token';
-import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
-import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
+import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/generated/dummy_e_r_c20_token';
+import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/generated/dummy_e_r_c721_token';
+import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/generated/e_r_c20_proxy';
+import { ERC721ProxyContract } from '../../src/generated_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';
@@ -144,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,
@@ -152,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 () => {
@@ -160,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,
@@ -170,7 +169,7 @@ describe('Asset Transfer Proxies', () => {
from: notAuthorized,
},
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -217,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,
@@ -225,7 +224,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -247,7 +246,6 @@ describe('Asset Transfer Proxies', () => {
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
- const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(1);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc721Proxy.transferFrom.sendTransactionAsync(
@@ -274,9 +272,8 @@ describe('Asset Transfer Proxies', () => {
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
- const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(0);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -284,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 () => {
@@ -297,9 +294,8 @@ describe('Asset Transfer Proxies', () => {
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
- const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(500);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
@@ -307,7 +303,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: exchangeAddress },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if allowances are too low', async () => {
@@ -325,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,
@@ -335,7 +331,7 @@ describe('Asset Transfer Proxies', () => {
from: notAuthorized,
},
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
it('should throw if requesting address is not authorized', async () => {
@@ -346,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,
@@ -354,7 +350,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -404,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,
@@ -412,7 +408,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: notAuthorized },
),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});