aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-23 04:02:21 +0800
committerFabio Berger <me@fabioberger.com>2018-05-23 04:02:21 +0800
commit2b793f372abc444702406539588f2101d9dc5307 (patch)
tree5d407c63d4fc5ebaa9537bf0bca2346c684a1a82 /packages/contracts/test/exchange
parent9119ee14b6d49b2c339b786f92913ff8a93ff610 (diff)
parent4cfeb6b8ace9c1613ac0581bd6ea52ff183701f9 (diff)
downloaddexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.gz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.bz2
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.lz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.xz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.zst
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.zip
Merge branch 'v2-prototype' into refactor/contracts/remove0xjsDep
* v2-prototype: Fix tslint issues Add `are` to boolean naming conventions Fix tslint Fix the tsutils version, fixing ts typings issue Rename some variables in multi_sig_with_time_lock.ts Remove extra awaitTransactionMinedAsync calls Update artifacts Update yarn.lock Fix warnings in Metacoin Upgrade UglifyJS to include ES6 support Add CancelOrder and MatchOrder types Add missing return types Ignore classnames linter rule Apply changes to test/exchange/match_orders.ts Fix some unhandled promise rejections Add awaitTransactionMinedAsync after every sent transaction Add missing blockchainLifecycle calls to contracts tests # Conflicts: # packages/contracts/src/utils/exchange_wrapper.ts # packages/contracts/test/asset_proxy/proxies.ts # packages/contracts/test/exchange/dispatcher.ts # packages/contracts/test/multi_sig_with_time_lock.ts
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r--packages/contracts/test/exchange/core.ts68
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts169
-rw-r--r--packages/contracts/test/exchange/libs.ts6
-rw-r--r--packages/contracts/test/exchange/match_orders.ts24
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts14
-rw-r--r--packages/contracts/test/exchange/transactions.ts11
-rw-r--r--packages/contracts/test/exchange/wrapper.ts60
7 files changed, 241 insertions, 111 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index a8a402555..a54ec7692 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -63,6 +63,12 @@ describe('Exchange core', () => {
let zeroEx: ZeroEx;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -94,12 +100,18 @@ describe('Exchange core', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerAssetAddress = erc20TokenA.address;
defaultTakerAssetAddress = erc20TokenB.address;
@@ -521,23 +533,39 @@ describe('Exchange core', () => {
});
it('should throw if maker allowances are too low to fill order', async () => {
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: makerAddress,
- });
- expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
it('should throw if taker allowances are too low to fill order', async () => {
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: takerAddress,
- });
- expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
it('should not change erc20Balances if an order is expired', async () => {
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index 3a09eb122..a2238bd10 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -36,6 +36,12 @@ describe('AssetProxyDispatcher', () => {
let erc721Wrapper: ERC721Wrapper;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
// Setup accounts & addresses
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, notOwner, makerAddress, takerAddress] = accounts);
@@ -55,12 +61,18 @@ describe('AssetProxyDispatcher', () => {
provider,
txDefaults,
);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -71,11 +83,14 @@ describe('AssetProxyDispatcher', () => {
describe('registerAssetProxy', () => {
it('should record proxy upon registration', async () => {
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -84,21 +99,27 @@ describe('AssetProxyDispatcher', () => {
it('should be able to record multiple proxies', async () => {
// Record first proxy
const prevERC20ProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevERC20ProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevERC20ProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Record another proxy
const prevERC721ProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC721,
- erc721Proxy.address,
- prevERC721ProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC721,
+ erc721Proxy.address,
+ prevERC721ProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721);
expect(proxyAddress).to.be.equal(erc721Proxy.address);
@@ -107,11 +128,14 @@ describe('AssetProxyDispatcher', () => {
it('should replace proxy address upon re-registration', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -124,11 +148,14 @@ describe('AssetProxyDispatcher', () => {
// Register new ERC20 Transfer Proxy contract
const newAddress = newErc20TransferProxy.address;
const currentAddress = erc20Proxy.address;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newAddress,
- currentAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ newAddress,
+ currentAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify new asset proxy has replaced initial version
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
@@ -138,11 +165,14 @@ describe('AssetProxyDispatcher', () => {
it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -160,21 +190,27 @@ describe('AssetProxyDispatcher', () => {
it('should be able to reset proxy address to NULL', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// The following transaction will reset the proxy address
const newProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newProxyAddress,
- erc20Proxy.address,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ newProxyAddress,
+ erc20Proxy.address,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const finalProxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(finalProxyAddress).to.be.equal(newProxyAddress);
@@ -208,11 +244,14 @@ describe('AssetProxyDispatcher', () => {
describe('getAssetProxy', () => {
it('should return correct address of registered proxy', async () => {
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -228,23 +267,29 @@ describe('AssetProxyDispatcher', () => {
it('should dispatch transfer to registered proxy', async () => {
// Register ERC20 proxy
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Construct metadata for ERC20 proxy
const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
- await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index 9af5916dd..5c530a9b1 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -25,6 +25,12 @@ describe('Exchange libs', () => {
let libs: TestLibsContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index bdf4f54fb..9f8f6db44 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -78,6 +78,12 @@ describe('matchOrders', () => {
let matchOrderTester: MatchOrderTester;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
// Create accounts
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([
@@ -114,12 +120,18 @@ describe('matchOrders', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
// Authorize ERC20 and ERC721 trades by exchange
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Set default addresses
defaultERC20MakerAssetAddress = erc20TokenA.address;
defaultERC20TakerAssetAddress = erc20TokenB.address;
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 7dac28c17..91614c666 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -25,6 +25,12 @@ describe('MixinSignatureValidator', () => {
let signatureValidator: TestSignatureValidatorContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
signatureValidator = await TestSignatureValidatorContract.deployFrom0xArtifactAsync(
@@ -60,12 +66,12 @@ describe('MixinSignatureValidator', () => {
it('should return true with a valid signature', async () => {
const orderHashHex = orderUtils.getOrderHashHex(signedOrder);
- const success = await signatureValidator.publicIsValidSignature.callAsync(
+ const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
signedOrder.signature,
);
- expect(success).to.be.true();
+ expect(isValidSignature).to.be.true();
});
it('should return false with an invalid signature', async () => {
@@ -79,12 +85,12 @@ describe('MixinSignatureValidator', () => {
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
signedOrder.signature = invalidSigHex;
const orderHashHex = orderUtils.getOrderHashHex(signedOrder);
- const success = await signatureValidator.publicIsValidSignature.callAsync(
+ const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
signedOrder.signature,
);
- expect(success).to.be.false();
+ expect(isValidSignature).to.be.false();
});
});
});
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index cd18b60ed..42e2429bb 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -58,6 +58,12 @@ describe('Exchange transactions', () => {
let defaultTakerTokenAddress: string;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, senderAddress, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -76,7 +82,10 @@ describe('Exchange transactions', () => {
exchangeWrapper = new ExchangeWrapper(exchange);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerTokenAddress = erc20TokenA.address;
defaultTakerTokenAddress = erc20TokenB.address;
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 4ff530874..99f23a5db 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -54,6 +54,12 @@ describe('Exchange wrappers', () => {
let defaultTakerAssetAddress: string;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -81,12 +87,18 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerAssetAddress = erc20TokenA.address;
defaultTakerAssetAddress = erc20TokenB.address;
@@ -244,13 +256,19 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if maker allowances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder();
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(newBalances).to.be.deep.equal(erc20Balances);
@@ -258,13 +276,19 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if taker allowances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder();
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(newBalances).to.be.deep.equal(erc20Balances);