aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-05-22 07:39:07 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-05-22 07:52:49 +0800
commit2c496a92adaef4132f6b0a135e61bad7b26b18bd (patch)
tree15466ce417120907a7b950c22e8e23230c09f746 /packages/contracts/test/asset_proxy
parent4ca8903a21d5a78ace5bff3fc5bbc917e369cbfe (diff)
downloaddexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar.gz
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar.bz2
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar.lz
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar.xz
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.tar.zst
dexon-sol-tools-2c496a92adaef4132f6b0a135e61bad7b26b18bd.zip
Add awaitTransactionMinedAsync after every sent transaction
Diffstat (limited to 'packages/contracts/test/asset_proxy')
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts47
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts85
2 files changed, 87 insertions, 45 deletions
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index bbdcfb742..52e9ea87f 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -48,12 +48,18 @@ describe('Authorizable', () => {
).to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to add an authorized address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const isAuthorized = await authorizable.authorized.callAsync(address);
expect(isAuthorized).to.be.true();
});
it('should throw if owner attempts to authorize a duplicate address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
return expect(
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
).to.be.rejectedWith(constants.REVERT);
@@ -62,7 +68,10 @@ describe('Authorizable', () => {
describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
return expect(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: notOwner,
@@ -71,10 +80,16 @@ describe('Authorizable', () => {
});
it('should allow owner to remove an authorized address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
- await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const isAuthorized = await authorizable.authorized.callAsync(address);
expect(isAuthorized).to.be.false();
});
@@ -92,16 +107,22 @@ describe('Authorizable', () => {
it('should return all authorized addresses', async () => {
const initial = await authorizable.getAuthorizedAddresses.callAsync();
expect(initial).to.have.length(0);
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
expect(afterAdd).to.have.length(1);
expect(afterAdd).to.include(address);
- await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
expect(afterRemove).to.have.length(0);
});
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index e64482c8f..27b7f3049 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -55,18 +55,24 @@ describe('Asset Transfer Proxies', () => {
[zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
[erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
erc721Proxy = await erc721Wrapper.deployProxyAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync();
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerTokenId = erc721Balances[makerAddress][erc721Token.address][0];
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
zeroEx = new ZeroEx(provider, {
networkId: constants.TESTRPC_NETWORK_ID,
@@ -86,12 +92,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -109,12 +118,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(0);
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -132,9 +144,12 @@ describe('Asset Transfer Proxies', () => {
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
const transferAmount = new BigNumber(10);
- await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Perform a transfer; expect this to fail.
return expect(
erc20Proxy.transferFrom.sendTransactionAsync(
@@ -185,7 +200,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(res.logs.length).to.equal(numTransfers);
@@ -238,12 +253,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(1);
- await erc721Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
@@ -303,9 +321,12 @@ describe('Asset Transfer Proxies', () => {
erc721MakerTokenId,
);
// Remove transfer approval for makerAddress.
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Perform a transfer; expect this to fail.
const amount = new BigNumber(1);
return expect(
@@ -362,7 +383,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs.length).to.equal(numTransfers);
const newOwnerMakerAssetA = await erc721Token.ownerOf.callAsync(makerTokenIdA);