Merge pull request #601 from 0xProject/contracts-test-fixes
Contracts test fixes
This commit is contained in:
@@ -20,6 +20,7 @@ export const constants = {
|
||||
INVALID_OPCODE: 'invalid opcode',
|
||||
REVERT: 'revert',
|
||||
TESTRPC_NETWORK_ID: 50,
|
||||
AWAIT_TRANSACTION_MINED_MS: 100,
|
||||
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
|
||||
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
|
||||
MAX_TOKEN_APPROVE_GAS: 60000,
|
||||
|
||||
@@ -19,6 +19,12 @@ describe('Authorizable', () => {
|
||||
let notOwner: string;
|
||||
let address: string;
|
||||
let authorizable: MixinAuthorizableContract;
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = address = accounts[0];
|
||||
@@ -42,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);
|
||||
@@ -56,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,
|
||||
@@ -65,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();
|
||||
});
|
||||
@@ -86,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);
|
||||
});
|
||||
|
||||
@@ -39,6 +39,12 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
let zeroEx: ZeroEx;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const usedAddresses = ([owner, notAuthorized, exchangeAddress, makerAddress, takerAddress] = accounts);
|
||||
@@ -49,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,
|
||||
@@ -80,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();
|
||||
@@ -103,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();
|
||||
@@ -126,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(
|
||||
@@ -179,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);
|
||||
@@ -200,7 +221,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const toAddresses = _.times(numTransfers, () => takerAddress);
|
||||
const amounts = _.times(numTransfers, () => amount);
|
||||
|
||||
expect(
|
||||
return expect(
|
||||
erc20Proxy.batchTransferFrom.sendTransactionAsync(
|
||||
assetMetadata,
|
||||
fromAddresses,
|
||||
@@ -232,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);
|
||||
@@ -297,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(
|
||||
@@ -356,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);
|
||||
@@ -378,7 +405,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const toAddresses = _.times(numTransfers, () => takerAddress);
|
||||
const amounts = _.times(numTransfers, () => new BigNumber(1));
|
||||
|
||||
expect(
|
||||
return expect(
|
||||
erc721Proxy.batchTransferFrom.sendTransactionAsync(
|
||||
assetMetadata,
|
||||
fromAddresses,
|
||||
|
||||
@@ -20,6 +20,13 @@ describe('EtherToken', () => {
|
||||
const gasPrice = ZeroEx.toBaseUnitAmount(new BigNumber(20), 9);
|
||||
let zeroEx: ZeroEx;
|
||||
let etherTokenAddress: string;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
account = accounts[0];
|
||||
|
||||
@@ -61,6 +61,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);
|
||||
@@ -93,12 +99,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;
|
||||
@@ -520,23 +532,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 () => {
|
||||
|
||||
@@ -36,6 +36,12 @@ describe('AssetProxyDispatcher', () => {
|
||||
let erc20Wrapper: ERC20Wrapper;
|
||||
let erc721Wrapper: ERC721Wrapper;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Setup accounts & addresses
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
@@ -56,12 +62,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();
|
||||
@@ -72,11 +84,14 @@ describe('AssetProxyDispatcher', () => {
|
||||
describe('registerAssetProxy', () => {
|
||||
it('should record proxy upon registration', async () => {
|
||||
const prevProxyAddress = ZeroEx.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);
|
||||
@@ -85,21 +100,27 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should be able to record multiple proxies', async () => {
|
||||
// Record first proxy
|
||||
const prevERC20ProxyAddress = ZeroEx.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 = ZeroEx.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);
|
||||
@@ -108,11 +129,14 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should replace proxy address upon re-registration', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.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);
|
||||
@@ -125,11 +149,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);
|
||||
@@ -139,11 +166,14 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.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);
|
||||
@@ -161,21 +191,27 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should be able to reset proxy address to NULL', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.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 = ZeroEx.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);
|
||||
@@ -209,11 +245,14 @@ describe('AssetProxyDispatcher', () => {
|
||||
describe('getAssetProxy', () => {
|
||||
it('should return correct address of registered proxy', async () => {
|
||||
const prevProxyAddress = ZeroEx.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);
|
||||
@@ -229,23 +268,29 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should dispatch transfer to registered proxy', async () => {
|
||||
// Register ERC20 proxy
|
||||
const prevProxyAddress = ZeroEx.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();
|
||||
|
||||
@@ -25,6 +25,12 @@ describe('Exchange libs', () => {
|
||||
let orderFactory: OrderFactory;
|
||||
let libs: TestLibsContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const makerAddress = accounts[0];
|
||||
|
||||
@@ -78,6 +78,12 @@ describe('matchOrders', () => {
|
||||
|
||||
let zeroEx: ZeroEx;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Create accounts
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
@@ -119,12 +125,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;
|
||||
|
||||
@@ -25,6 +25,12 @@ describe('MixinSignatureValidator', () => {
|
||||
let orderFactory: OrderFactory;
|
||||
let signatureValidator: TestSignatureValidatorContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const makerAddress = accounts[0];
|
||||
|
||||
@@ -61,6 +61,12 @@ describe('Exchange transactions', () => {
|
||||
|
||||
let zeroEx: ZeroEx;
|
||||
|
||||
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);
|
||||
@@ -84,7 +90,10 @@ describe('Exchange transactions', () => {
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
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;
|
||||
|
||||
@@ -56,6 +56,12 @@ describe('Exchange wrappers', () => {
|
||||
|
||||
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);
|
||||
@@ -88,12 +94,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;
|
||||
@@ -251,13 +263,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);
|
||||
@@ -265,13 +283,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);
|
||||
|
||||
@@ -32,6 +32,12 @@ describe('LibBytes', () => {
|
||||
const testBytes32 = '0x102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f01020';
|
||||
const testUint256 = new BigNumber(testBytes32, 16);
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
// Setup accounts & addresses
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
|
||||
@@ -45,6 +45,12 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
describe('changeTimeLock', () => {
|
||||
describe('initially non-time-locked', async () => {
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before('deploy a wallet', async () => {
|
||||
multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
|
||||
artifacts.MultiSigWalletWithTimeLock,
|
||||
@@ -74,8 +80,8 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
args: [SECONDS_TIME_LOCKED.toNumber()],
|
||||
};
|
||||
const txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
|
||||
const subRes = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
|
||||
const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
|
||||
SubmissionContractEventArgs
|
||||
>;
|
||||
|
||||
@@ -94,14 +100,14 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
args: [SECONDS_TIME_LOCKED.toNumber()],
|
||||
};
|
||||
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
|
||||
const subRes = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
|
||||
const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
|
||||
SubmissionContractEventArgs
|
||||
>;
|
||||
|
||||
txId = log.args.transactionId;
|
||||
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, { from: owners[1] });
|
||||
const res = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
expect(res.logs).to.have.length(2);
|
||||
|
||||
const blockNum = await web3Wrapper.getBlockNumberAsync();
|
||||
@@ -121,18 +127,19 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
args: [SECONDS_TIME_LOCKED.toNumber()],
|
||||
};
|
||||
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
|
||||
const subRes = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
|
||||
const txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
|
||||
SubmissionContractEventArgs
|
||||
>;
|
||||
|
||||
txId = log.args.transactionId;
|
||||
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, { from: owners[1] });
|
||||
await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
|
||||
expect(initialSecondsTimeLocked).to.be.equal(0);
|
||||
|
||||
txHash = await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
|
||||
const res = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const res = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
expect(res.logs).to.have.length(2);
|
||||
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
|
||||
@@ -140,6 +147,12 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
});
|
||||
});
|
||||
describe('initially time-locked', async () => {
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before('deploy a wallet', async () => {
|
||||
multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
|
||||
artifacts.MultiSigWalletWithTimeLock,
|
||||
@@ -161,16 +174,16 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
args: [newSecondsTimeLocked],
|
||||
};
|
||||
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
|
||||
const subRes = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
|
||||
let txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
|
||||
SubmissionContractEventArgs
|
||||
>;
|
||||
txId = log.args.transactionId;
|
||||
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, {
|
||||
from: owners[1],
|
||||
});
|
||||
const confRes = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
expect(confRes.logs).to.have.length(2);
|
||||
txReceipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
expect(txReceipt.logs).to.have.length(2);
|
||||
});
|
||||
const newSecondsTimeLocked = 0;
|
||||
it('should throw if it has enough confirmations but is not past the time lock', async () => {
|
||||
@@ -181,7 +194,10 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
it('should execute if it has enough confirmations and is past the time lock', async () => {
|
||||
await web3Wrapper.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber());
|
||||
await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
|
||||
await web3Wrapper.awaitTransactionMinedAsync(
|
||||
await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
|
||||
expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked);
|
||||
|
||||
@@ -24,6 +24,12 @@ describe('TokenRegistry', () => {
|
||||
let notOwner: string;
|
||||
let tokenReg: TokenRegistryContract;
|
||||
let tokenRegWrapper: TokenRegWrapper;
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
@@ -137,9 +143,12 @@ describe('TokenRegistry', () => {
|
||||
});
|
||||
|
||||
it('should change the token name when called by owner', async () => {
|
||||
await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, {
|
||||
from: owner,
|
||||
});
|
||||
await web3Wrapper.awaitTransactionMinedAsync(
|
||||
await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, {
|
||||
from: owner,
|
||||
}),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
const [newData, oldData] = await Promise.all([
|
||||
tokenRegWrapper.getTokenByNameAsync(token2.name),
|
||||
tokenRegWrapper.getTokenByNameAsync(token1.name),
|
||||
@@ -176,7 +185,10 @@ describe('TokenRegistry', () => {
|
||||
});
|
||||
|
||||
it('should change the token symbol when called by owner', async () => {
|
||||
await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner });
|
||||
await web3Wrapper.awaitTransactionMinedAsync(
|
||||
await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner }),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
const [newData, oldData] = await Promise.all([
|
||||
tokenRegWrapper.getTokenBySymbolAsync(token2.symbol),
|
||||
tokenRegWrapper.getTokenBySymbolAsync(token1.symbol),
|
||||
@@ -217,9 +229,12 @@ describe('TokenRegistry', () => {
|
||||
|
||||
it('should remove token metadata when called by owner', async () => {
|
||||
const index = new BigNumber(0);
|
||||
await tokenReg.removeToken.sendTransactionAsync(token1.address, index, {
|
||||
from: owner,
|
||||
});
|
||||
await web3Wrapper.awaitTransactionMinedAsync(
|
||||
await tokenReg.removeToken.sendTransactionAsync(token1.address, index, {
|
||||
from: owner,
|
||||
}),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
|
||||
expect(tokenData).to.be.deep.equal(nullToken);
|
||||
});
|
||||
|
||||
@@ -27,6 +27,12 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
let tokenAddress: string;
|
||||
let token: DummyERC20TokenContract;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
@@ -40,7 +46,10 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
constants.DUMMY_TOKEN_DECIMALS,
|
||||
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
|
||||
);
|
||||
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner });
|
||||
await web3Wrapper.awaitTransactionMinedAsync(
|
||||
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
tokenAddress = token.address;
|
||||
});
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -26,6 +26,12 @@ describe('ZRXToken', () => {
|
||||
let zrxToken: ZRXTokenContract;
|
||||
let zrxAddress: string;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
before(async () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
|
||||
Reference in New Issue
Block a user