Replace constant.REVERT test assertions with expectRevertOrAlwaysFailingTransaction
This commit is contained in:
@@ -7,7 +7,7 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
// throws if the given promise does not reject with one of two expected error
|
// throws if the given promise does not reject with one of two expected error
|
||||||
// messages.
|
// messages.
|
||||||
export const expectRevertOrAlwaysFailingTransaction = <T>(p: Promise<T>) => {
|
export function expectRevertOrAlwaysFailingTransaction<T>(p: Promise<T>): PromiseLike<void> {
|
||||||
return expect(p)
|
return expect(p)
|
||||||
.to.be.rejected()
|
.to.be.rejected()
|
||||||
.then(e => {
|
.then(e => {
|
||||||
@@ -17,4 +17,4 @@ export const expectRevertOrAlwaysFailingTransaction = <T>(p: Promise<T>) => {
|
|||||||
_.includes(err.message, constants.ALWAYS_FAILING_TRANSACTION),
|
_.includes(err.message, constants.ALWAYS_FAILING_TRANSACTION),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable';
|
import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
|
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
|
||||||
@@ -44,9 +45,9 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
describe('addAuthorizedAddress', () => {
|
describe('addAuthorizedAddress', () => {
|
||||||
it('should throw if not called by owner', async () => {
|
it('should throw if not called by owner', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
|
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
it('should allow owner to add an authorized address', async () => {
|
it('should allow owner to add an authorized address', async () => {
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
@@ -61,9 +62,9 @@ describe('Authorizable', () => {
|
|||||||
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,11 +74,11 @@ describe('Authorizable', () => {
|
|||||||
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
|
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
|
||||||
from: notOwner,
|
from: notOwner,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
@@ -96,11 +97,11 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if owner attempts to remove an address that is not authorized', async () => {
|
it('should throw if owner attempts to remove an address that is not authorized', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
|
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
|
||||||
from: owner,
|
from: owner,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/d
|
|||||||
import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c721_token';
|
import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c721_token';
|
||||||
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
|
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
|
||||||
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
|
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -144,7 +145,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
// Perform a transfer; expect this to fail.
|
// Perform a transfer; expect this to fail.
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc20Proxy.transferFrom.sendTransactionAsync(
|
erc20Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -152,7 +153,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
transferAmount,
|
transferAmount,
|
||||||
{ from: notAuthorized },
|
{ from: notAuthorized },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if requesting address is not authorized', async () => {
|
it('should throw if requesting address is not authorized', async () => {
|
||||||
@@ -160,7 +161,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
|
const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
|
||||||
// Perform a transfer from makerAddress to takerAddress
|
// Perform a transfer from makerAddress to takerAddress
|
||||||
const amount = new BigNumber(10);
|
const amount = new BigNumber(10);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc20Proxy.transferFrom.sendTransactionAsync(
|
erc20Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -170,7 +171,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
from: notAuthorized,
|
from: notAuthorized,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
const toAddresses = _.times(numTransfers, () => takerAddress);
|
const toAddresses = _.times(numTransfers, () => takerAddress);
|
||||||
const amounts = _.times(numTransfers, () => amount);
|
const amounts = _.times(numTransfers, () => amount);
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc20Proxy.batchTransferFrom.sendTransactionAsync(
|
erc20Proxy.batchTransferFrom.sendTransactionAsync(
|
||||||
assetMetadata,
|
assetMetadata,
|
||||||
fromAddresses,
|
fromAddresses,
|
||||||
@@ -225,7 +226,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
amounts,
|
amounts,
|
||||||
{ from: notAuthorized },
|
{ from: notAuthorized },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -276,7 +277,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
// Perform a transfer from makerAddress to takerAddress
|
// Perform a transfer from makerAddress to takerAddress
|
||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = new BigNumber(0);
|
const amount = new BigNumber(0);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc721Proxy.transferFrom.sendTransactionAsync(
|
erc721Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -284,7 +285,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
amount,
|
amount,
|
||||||
{ from: exchangeAddress },
|
{ from: exchangeAddress },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if transferring > 1 amount of a token', async () => {
|
it('should throw if transferring > 1 amount of a token', async () => {
|
||||||
@@ -299,7 +300,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
// Perform a transfer from makerAddress to takerAddress
|
// Perform a transfer from makerAddress to takerAddress
|
||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = new BigNumber(500);
|
const amount = new BigNumber(500);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc721Proxy.transferFrom.sendTransactionAsync(
|
erc721Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -307,7 +308,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
amount,
|
amount,
|
||||||
{ from: exchangeAddress },
|
{ from: exchangeAddress },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if allowances are too low', async () => {
|
it('should throw if allowances are too low', async () => {
|
||||||
@@ -325,7 +326,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
);
|
);
|
||||||
// Perform a transfer; expect this to fail.
|
// Perform a transfer; expect this to fail.
|
||||||
const amount = new BigNumber(1);
|
const amount = new BigNumber(1);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc20Proxy.transferFrom.sendTransactionAsync(
|
erc20Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -335,7 +336,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
from: notAuthorized,
|
from: notAuthorized,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if requesting address is not authorized', async () => {
|
it('should throw if requesting address is not authorized', async () => {
|
||||||
@@ -346,7 +347,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
);
|
);
|
||||||
// Perform a transfer from makerAddress to takerAddress
|
// Perform a transfer from makerAddress to takerAddress
|
||||||
const amount = new BigNumber(1);
|
const amount = new BigNumber(1);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc721Proxy.transferFrom.sendTransactionAsync(
|
erc721Proxy.transferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -354,7 +355,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
amount,
|
amount,
|
||||||
{ from: notAuthorized },
|
{ from: notAuthorized },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -404,7 +405,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
const toAddresses = _.times(numTransfers, () => takerAddress);
|
const toAddresses = _.times(numTransfers, () => takerAddress);
|
||||||
const amounts = _.times(numTransfers, () => new BigNumber(1));
|
const amounts = _.times(numTransfers, () => new BigNumber(1));
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
erc721Proxy.batchTransferFrom.sendTransactionAsync(
|
erc721Proxy.batchTransferFrom.sendTransactionAsync(
|
||||||
assetMetadata,
|
assetMetadata,
|
||||||
fromAddresses,
|
fromAddresses,
|
||||||
@@ -412,7 +413,7 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
amounts,
|
amounts,
|
||||||
{ from: notAuthorized },
|
{ from: notAuthorized },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ import {
|
|||||||
FillContractEventArgs,
|
FillContractEventArgs,
|
||||||
} from '../../src/contract_wrappers/generated/exchange';
|
} from '../../src/contract_wrappers/generated/exchange';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -415,9 +416,7 @@ describe('Exchange core', () => {
|
|||||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
|
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
|
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
});
|
});
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if signature is invalid', async () => {
|
it('should throw if signature is invalid', async () => {
|
||||||
@@ -432,9 +431,7 @@ describe('Exchange core', () => {
|
|||||||
const invalidSigBuff = Buffer.concat([v, invalidR, invalidS, signatureType]);
|
const invalidSigBuff = Buffer.concat([v, invalidR, invalidS, signatureType]);
|
||||||
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
|
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
|
||||||
signedOrder.signature = invalidSigHex;
|
signedOrder.signature = invalidSigHex;
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if makerAssetAmount is 0', async () => {
|
it('should throw if makerAssetAmount is 0', async () => {
|
||||||
@@ -442,9 +439,7 @@ describe('Exchange core', () => {
|
|||||||
makerAssetAmount: new BigNumber(0),
|
makerAssetAmount: new BigNumber(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if takerAssetAmount is 0', async () => {
|
it('should throw if takerAssetAmount is 0', async () => {
|
||||||
@@ -452,19 +447,17 @@ describe('Exchange core', () => {
|
|||||||
takerAssetAmount: new BigNumber(0),
|
takerAssetAmount: new BigNumber(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if takerAssetFillAmount is 0', async () => {
|
it('should throw if takerAssetFillAmount is 0', async () => {
|
||||||
signedOrder = orderFactory.newSignedOrder();
|
signedOrder = orderFactory.newSignedOrder();
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
takerAssetFillAmount: new BigNumber(0),
|
takerAssetFillAmount: new BigNumber(0),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if maker erc20Balances are too low to fill order', async () => {
|
it('should throw if maker erc20Balances are too low to fill order', async () => {
|
||||||
@@ -472,9 +465,7 @@ describe('Exchange core', () => {
|
|||||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
|
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if taker erc20Balances are too low to fill order', async () => {
|
it('should throw if taker erc20Balances are too low to fill order', async () => {
|
||||||
@@ -482,9 +473,7 @@ describe('Exchange core', () => {
|
|||||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
|
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if maker allowances are too low to fill order', async () => {
|
it('should throw if maker allowances are too low to fill order', async () => {
|
||||||
@@ -497,9 +486,7 @@ describe('Exchange core', () => {
|
|||||||
// HACK: `rejectWith` returns a "promise-like" type, but not an actual "Promise", so TSLint
|
// HACK: `rejectWith` returns a "promise-like" type, but not an actual "Promise", so TSLint
|
||||||
// complains, even though we do need to `await` it. So we disable the TSLint error below.
|
// complains, even though we do need to `await` it. So we disable the TSLint error below.
|
||||||
// tslint:disable-next-line:await-promise
|
// tslint:disable-next-line:await-promise
|
||||||
await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
await expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if taker allowances are too low to fill order', async () => {
|
it('should throw if taker allowances are too low to fill order', async () => {
|
||||||
@@ -509,12 +496,7 @@ describe('Exchange core', () => {
|
|||||||
}),
|
}),
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
// HACK: `rejectWith` returns a "promise-like" type, but not an actual "Promise", so TSLint
|
await expectRevertOrAlwaysFailingTransaction(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress));
|
||||||
// complains, even though we do need to `await` it. So we disable the TSLint error below.
|
|
||||||
// tslint:disable-next-line:await-promise
|
|
||||||
await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if an order is expired', async () => {
|
it('should throw if an order is expired', async () => {
|
||||||
@@ -542,9 +524,7 @@ describe('Exchange core', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if not sent by maker', async () => {
|
it('should throw if not sent by maker', async () => {
|
||||||
return expect(exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if makerAssetAmount is 0', async () => {
|
it('should throw if makerAssetAmount is 0', async () => {
|
||||||
@@ -552,9 +532,7 @@ describe('Exchange core', () => {
|
|||||||
makerAssetAmount: new BigNumber(0),
|
makerAssetAmount: new BigNumber(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if takerAssetAmount is 0', async () => {
|
it('should throw if takerAssetAmount is 0', async () => {
|
||||||
@@ -562,9 +540,7 @@ describe('Exchange core', () => {
|
|||||||
takerAssetAmount: new BigNumber(0),
|
takerAssetAmount: new BigNumber(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to cancel a full order', async () => {
|
it('should be able to cancel a full order', async () => {
|
||||||
@@ -632,16 +608,16 @@ describe('Exchange core', () => {
|
|||||||
const makerEpoch = new BigNumber(1);
|
const makerEpoch = new BigNumber(1);
|
||||||
await exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
|
await exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
|
||||||
const lesserMakerEpoch = new BigNumber(0);
|
const lesserMakerEpoch = new BigNumber(0);
|
||||||
return expect(exchangeWrapper.cancelOrdersUpToAsync(lesserMakerEpoch, makerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.cancelOrdersUpToAsync(lesserMakerEpoch, makerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail to set makerEpoch equal to existing makerEpoch', async () => {
|
it('should fail to set makerEpoch equal to existing makerEpoch', async () => {
|
||||||
const makerEpoch = new BigNumber(1);
|
const makerEpoch = new BigNumber(1);
|
||||||
await exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
|
await exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
|
||||||
return expect(exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -749,9 +725,9 @@ describe('Exchange core', () => {
|
|||||||
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
||||||
// Call Exchange
|
// Call Exchange
|
||||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when taker does not own the token with id takerAssetId', async () => {
|
it('should throw when taker does not own the token with id takerAssetId', async () => {
|
||||||
@@ -771,9 +747,9 @@ describe('Exchange core', () => {
|
|||||||
expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress);
|
expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress);
|
||||||
// Call Exchange
|
// Call Exchange
|
||||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when makerAssetAmount is greater than 1', async () => {
|
it('should throw when makerAssetAmount is greater than 1', async () => {
|
||||||
@@ -793,9 +769,9 @@ describe('Exchange core', () => {
|
|||||||
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
||||||
// Call Exchange
|
// Call Exchange
|
||||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when takerAssetAmount is greater than 1', async () => {
|
it('should throw when takerAssetAmount is greater than 1', async () => {
|
||||||
@@ -815,9 +791,9 @@ describe('Exchange core', () => {
|
|||||||
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
||||||
// Call Exchange
|
// Call Exchange
|
||||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw on partial fill', async () => {
|
it('should throw on partial fill', async () => {
|
||||||
@@ -837,9 +813,9 @@ describe('Exchange core', () => {
|
|||||||
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
||||||
// Call Exchange
|
// Call Exchange
|
||||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should successfully fill order when makerAsset is ERC721 and takerAsset is ERC20', async () => {
|
it('should successfully fill order when makerAsset is ERC721 and takerAsset is ERC20', async () => {
|
||||||
|
@@ -10,6 +10,7 @@ import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c2
|
|||||||
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
|
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
|
||||||
import { TestAssetProxyDispatcherContract } from '../../src/contract_wrappers/generated/test_asset_proxy_dispatcher';
|
import { TestAssetProxyDispatcherContract } from '../../src/contract_wrappers/generated/test_asset_proxy_dispatcher';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -177,14 +178,14 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
|
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
|
||||||
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
||||||
// The following transaction will throw because the currentAddress is no longer constants.NULL_ADDRESS
|
// The following transaction will throw because the currentAddress is no longer constants.NULL_ADDRESS
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||||
AssetProxyId.ERC20,
|
AssetProxyId.ERC20,
|
||||||
erc20Proxy.address,
|
erc20Proxy.address,
|
||||||
constants.NULL_ADDRESS,
|
constants.NULL_ADDRESS,
|
||||||
{ from: owner },
|
{ from: owner },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to reset proxy address to NULL', async () => {
|
it('should be able to reset proxy address to NULL', async () => {
|
||||||
@@ -218,26 +219,26 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
|
|
||||||
it('should throw if requesting address is not owner', async () => {
|
it('should throw if requesting address is not owner', async () => {
|
||||||
const prevProxyAddress = constants.NULL_ADDRESS;
|
const prevProxyAddress = constants.NULL_ADDRESS;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||||
AssetProxyId.ERC20,
|
AssetProxyId.ERC20,
|
||||||
erc20Proxy.address,
|
erc20Proxy.address,
|
||||||
prevProxyAddress,
|
prevProxyAddress,
|
||||||
{ from: notOwner },
|
{ from: notOwner },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if attempting to register a proxy to the incorrect id', async () => {
|
it('should throw if attempting to register a proxy to the incorrect id', async () => {
|
||||||
const prevProxyAddress = constants.NULL_ADDRESS;
|
const prevProxyAddress = constants.NULL_ADDRESS;
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||||
AssetProxyId.ERC721,
|
AssetProxyId.ERC721,
|
||||||
erc20Proxy.address,
|
erc20Proxy.address,
|
||||||
prevProxyAddress,
|
prevProxyAddress,
|
||||||
{ from: owner },
|
{ from: owner },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -307,7 +308,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
// Perform a transfer from makerAddress to takerAddress
|
// Perform a transfer from makerAddress to takerAddress
|
||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = new BigNumber(10);
|
const amount = new BigNumber(10);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
||||||
encodedProxyMetadata,
|
encodedProxyMetadata,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -315,7 +316,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
amount,
|
amount,
|
||||||
{ from: owner },
|
{ from: owner },
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -18,6 +18,7 @@ import {
|
|||||||
FillContractEventArgs,
|
FillContractEventArgs,
|
||||||
} from '../../src/contract_wrappers/generated/exchange';
|
} from '../../src/contract_wrappers/generated/exchange';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -639,9 +640,9 @@ describe('matchOrders', () => {
|
|||||||
// Cancel left order
|
// Cancel left order
|
||||||
await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress);
|
await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress);
|
||||||
// Match orders
|
// Match orders
|
||||||
return expect(
|
return exexpectRevertOrAlwaysFailingTransactionpect(
|
||||||
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
|
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should throw if right order is not fillable', async () => {
|
it('Should throw if right order is not fillable', async () => {
|
||||||
@@ -665,9 +666,9 @@ describe('matchOrders', () => {
|
|||||||
// Cancel right order
|
// Cancel right order
|
||||||
await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress);
|
await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress);
|
||||||
// Match orders
|
// Match orders
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
|
exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if there is not a positive spread', async () => {
|
it('should throw if there is not a positive spread', async () => {
|
||||||
@@ -689,7 +690,7 @@ describe('matchOrders', () => {
|
|||||||
feeRecipientAddress: feeRecipientAddressRight,
|
feeRecipientAddress: feeRecipientAddressRight,
|
||||||
});
|
});
|
||||||
// Match orders
|
// Match orders
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
||||||
signedOrderLeft,
|
signedOrderLeft,
|
||||||
signedOrderRight,
|
signedOrderRight,
|
||||||
@@ -697,7 +698,7 @@ describe('matchOrders', () => {
|
|||||||
erc20BalancesByOwner,
|
erc20BalancesByOwner,
|
||||||
erc721TokenIdsByOwner,
|
erc721TokenIdsByOwner,
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if the left maker asset is not equal to the right taker asset ', async () => {
|
it('should throw if the left maker asset is not equal to the right taker asset ', async () => {
|
||||||
@@ -719,7 +720,7 @@ describe('matchOrders', () => {
|
|||||||
feeRecipientAddress: feeRecipientAddressRight,
|
feeRecipientAddress: feeRecipientAddressRight,
|
||||||
});
|
});
|
||||||
// Match orders
|
// Match orders
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
||||||
signedOrderLeft,
|
signedOrderLeft,
|
||||||
signedOrderRight,
|
signedOrderRight,
|
||||||
@@ -727,7 +728,7 @@ describe('matchOrders', () => {
|
|||||||
erc20BalancesByOwner,
|
erc20BalancesByOwner,
|
||||||
erc721TokenIdsByOwner,
|
erc721TokenIdsByOwner,
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if the right maker asset is not equal to the left taker asset', async () => {
|
it('should throw if the right maker asset is not equal to the left taker asset', async () => {
|
||||||
@@ -749,7 +750,7 @@ describe('matchOrders', () => {
|
|||||||
feeRecipientAddress: feeRecipientAddressRight,
|
feeRecipientAddress: feeRecipientAddressRight,
|
||||||
});
|
});
|
||||||
// Match orders
|
// Match orders
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
matchOrderTester.matchOrdersAndVerifyBalancesAsync(
|
||||||
signedOrderLeft,
|
signedOrderLeft,
|
||||||
signedOrderRight,
|
signedOrderRight,
|
||||||
@@ -757,7 +758,7 @@ describe('matchOrders', () => {
|
|||||||
erc20BalancesByOwner,
|
erc20BalancesByOwner,
|
||||||
erc721TokenIdsByOwner,
|
erc721TokenIdsByOwner,
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer correct amounts when left order maker asset is an ERC721 token', async () => {
|
it('should transfer correct amounts when left order maker asset is an ERC721 token', async () => {
|
||||||
|
@@ -11,6 +11,7 @@ import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c2
|
|||||||
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
||||||
import { WhitelistContract } from '../../src/contract_wrappers/generated/whitelist';
|
import { WhitelistContract } from '../../src/contract_wrappers/generated/whitelist';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -126,8 +127,8 @@ describe('Exchange transactions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if not called by specified sender', async () => {
|
it('should throw if not called by specified sender', async () => {
|
||||||
return expect(exchangeWrapper.executeTransactionAsync(signedTx, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.executeTransactionAsync(signedTx, takerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -168,8 +169,8 @@ describe('Exchange transactions', () => {
|
|||||||
|
|
||||||
it('should throw if the a 0x transaction with the same transactionHash has already been executed', async () => {
|
it('should throw if the a 0x transaction with the same transactionHash has already been executed', async () => {
|
||||||
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
|
await exchangeWrapper.executeTransactionAsync(signedTx, senderAddress);
|
||||||
return expect(exchangeWrapper.executeTransactionAsync(signedTx, senderAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.executeTransactionAsync(signedTx, senderAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -187,8 +188,8 @@ describe('Exchange transactions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if not called by specified sender', async () => {
|
it('should throw if not called by specified sender', async () => {
|
||||||
return expect(exchangeWrapper.executeTransactionAsync(signedTx, makerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.executeTransactionAsync(signedTx, makerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c
|
|||||||
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
||||||
import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry';
|
import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
|
||||||
@@ -172,8 +173,8 @@ describe('Exchange wrappers', () => {
|
|||||||
expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -184,8 +185,8 @@ describe('Exchange wrappers', () => {
|
|||||||
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
|
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -485,11 +486,11 @@ describe('Exchange wrappers', () => {
|
|||||||
|
|
||||||
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
|
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
|
exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
|
||||||
takerAssetFillAmounts,
|
takerAssetFillAmounts,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -679,11 +680,11 @@ describe('Exchange wrappers', () => {
|
|||||||
orderFactory.newSignedOrder(),
|
orderFactory.newSignedOrder(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
|
exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
|
||||||
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -768,11 +769,11 @@ describe('Exchange wrappers', () => {
|
|||||||
orderFactory.newSignedOrder(),
|
orderFactory.newSignedOrder(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
|
exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
|
||||||
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -857,11 +858,11 @@ describe('Exchange wrappers', () => {
|
|||||||
orderFactory.newSignedOrder(),
|
orderFactory.newSignedOrder(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
|
exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
|
||||||
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -946,11 +947,11 @@ describe('Exchange wrappers', () => {
|
|||||||
orderFactory.newSignedOrder(),
|
orderFactory.newSignedOrder(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
|
exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
|
||||||
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import { TestLibBytesContract } from '../../src/contract_wrappers/generated/test_lib_bytes';
|
import { TestLibBytesContract } from '../../src/contract_wrappers/generated/test_lib_bytes';
|
||||||
import { artifacts } from '../../src/utils/artifacts';
|
import { artifacts } from '../../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
|
||||||
import { chaiSetup } from '../../src/utils/chai_setup';
|
import { chaiSetup } from '../../src/utils/chai_setup';
|
||||||
import { constants } from '../../src/utils/constants';
|
import { constants } from '../../src/utils/constants';
|
||||||
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
|
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
|
||||||
@@ -162,17 +163,13 @@ describe('LibBytes', () => {
|
|||||||
it('should fail if the byte array is too short to hold an address)', async () => {
|
it('should fail if the byte array is too short to hold an address)', async () => {
|
||||||
const shortByteArray = '0xabcdef';
|
const shortByteArray = '0xabcdef';
|
||||||
const offset = new BigNumber(0);
|
const offset = new BigNumber(0);
|
||||||
return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(shortByteArray, offset));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the length between the offset and end of the byte array is too short to hold an address)', async () => {
|
it('should fail if the length between the offset and end of the byte array is too short to hold an address)', async () => {
|
||||||
const byteArray = ethUtil.addHexPrefix(testAddress);
|
const byteArray = ethUtil.addHexPrefix(testAddress);
|
||||||
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
|
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
|
||||||
return expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(byteArray, badOffset));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,16 +203,14 @@ describe('LibBytes', () => {
|
|||||||
|
|
||||||
it('should fail if the byte array is too short to hold a bytes32)', async () => {
|
it('should fail if the byte array is too short to hold a bytes32)', async () => {
|
||||||
const offset = new BigNumber(0);
|
const offset = new BigNumber(0);
|
||||||
return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32)', async () => {
|
it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32)', async () => {
|
||||||
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
|
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
|
||||||
return expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -253,8 +248,8 @@ describe('LibBytes', () => {
|
|||||||
|
|
||||||
it('should fail if the byte array is too short to hold a uint256)', async () => {
|
it('should fail if the byte array is too short to hold a uint256)', async () => {
|
||||||
const offset = new BigNumber(0);
|
const offset = new BigNumber(0);
|
||||||
return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
constants.REVERT,
|
libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -263,9 +258,7 @@ describe('LibBytes', () => {
|
|||||||
const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256);
|
const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256);
|
||||||
const byteArray = ethUtil.bufferToHex(testUint256AsBuffer);
|
const byteArray = ethUtil.bufferToHex(testUint256AsBuffer);
|
||||||
const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
|
const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
|
||||||
return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadUint256.callAsync(byteArray, badOffset));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import {
|
|||||||
SubmissionContractEventArgs,
|
SubmissionContractEventArgs,
|
||||||
} from '../src/contract_wrappers/generated/multi_sig_wallet_with_time_lock';
|
} from '../src/contract_wrappers/generated/multi_sig_wallet_with_time_lock';
|
||||||
import { artifacts } from '../src/utils/artifacts';
|
import { artifacts } from '../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../src/utils/assertions';
|
||||||
import { chaiSetup } from '../src/utils/chai_setup';
|
import { chaiSetup } from '../src/utils/chai_setup';
|
||||||
import { constants } from '../src/utils/constants';
|
import { constants } from '../src/utils/constants';
|
||||||
import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
|
import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
|
||||||
@@ -69,9 +70,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when not called by wallet', async () => {
|
it('should throw when not called by wallet', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }),
|
multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw without enough confirmations', async () => {
|
it('should throw without enough confirmations', async () => {
|
||||||
@@ -80,10 +81,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
|||||||
const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
|
const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<SubmissionContractEventArgs>;
|
||||||
const txId = log.args.transactionId;
|
const txId = log.args.transactionId;
|
||||||
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
return expect(
|
|
||||||
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set confirmation time with enough confirmations', async () => {
|
it('should set confirmation time with enough confirmations', async () => {
|
||||||
@@ -149,9 +149,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
|||||||
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
|
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
|
||||||
});
|
});
|
||||||
it('should throw if it has enough confirmations but is not past the time lock', async () => {
|
it('should throw if it has enough confirmations but is not past the time lock', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should execute if it has enough confirmations and is past the time lock', async () => {
|
it('should execute if it has enough confirmations and is past the time lock', async () => {
|
||||||
|
@@ -9,6 +9,7 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry';
|
import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry';
|
||||||
import { artifacts } from '../src/utils/artifacts';
|
import { artifacts } from '../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../src/utils/assertions';
|
||||||
import { chaiSetup } from '../src/utils/chai_setup';
|
import { chaiSetup } from '../src/utils/chai_setup';
|
||||||
import { constants } from '../src/utils/constants';
|
import { constants } from '../src/utils/constants';
|
||||||
import { TokenRegWrapper } from '../src/utils/token_registry_wrapper';
|
import { TokenRegWrapper } from '../src/utils/token_registry_wrapper';
|
||||||
@@ -76,7 +77,7 @@ describe('TokenRegistry', () => {
|
|||||||
|
|
||||||
describe('addToken', () => {
|
describe('addToken', () => {
|
||||||
it('should throw when not called by owner', async () => {
|
it('should throw when not called by owner', async () => {
|
||||||
return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.REVERT);
|
return expectRevertOrAlwaysFailingTransaction(tokenRegWrapper.addTokenAsync(token1, notOwner));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add token metadata when called by owner', async () => {
|
it('should add token metadata when called by owner', async () => {
|
||||||
@@ -88,20 +89,18 @@ describe('TokenRegistry', () => {
|
|||||||
it('should throw if token already exists', async () => {
|
it('should throw if token already exists', async () => {
|
||||||
await tokenRegWrapper.addTokenAsync(token1, owner);
|
await tokenRegWrapper.addTokenAsync(token1, owner);
|
||||||
|
|
||||||
return expect(tokenRegWrapper.addTokenAsync(token1, owner)).to.be.rejectedWith(constants.REVERT);
|
return expectRevertOrAlwaysFailingTransaction(tokenRegWrapper.addTokenAsync(token1, owner));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if token address is null', async () => {
|
it('should throw if token address is null', async () => {
|
||||||
return expect(tokenRegWrapper.addTokenAsync(nullToken, owner)).to.be.rejectedWith(constants.REVERT);
|
return expectRevertOrAlwaysFailingTransaction(tokenRegWrapper.addTokenAsync(nullToken, owner));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if name already exists', async () => {
|
it('should throw if name already exists', async () => {
|
||||||
await tokenRegWrapper.addTokenAsync(token1, owner);
|
await tokenRegWrapper.addTokenAsync(token1, owner);
|
||||||
const duplicateNameToken = _.assign({}, token2, { name: token1.name });
|
const duplicateNameToken = _.assign({}, token2, { name: token1.name });
|
||||||
|
|
||||||
return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if symbol already exists', async () => {
|
it('should throw if symbol already exists', async () => {
|
||||||
@@ -110,9 +109,7 @@ describe('TokenRegistry', () => {
|
|||||||
symbol: token1.symbol,
|
symbol: token1.symbol,
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner)).to.be.rejectedWith(
|
return expectRevertOrAlwaysFailingTransaction(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner));
|
||||||
constants.REVERT,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -137,9 +134,9 @@ describe('TokenRegistry', () => {
|
|||||||
|
|
||||||
describe('setTokenName', () => {
|
describe('setTokenName', () => {
|
||||||
it('should throw when not called by owner', async () => {
|
it('should throw when not called by owner', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }),
|
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the token name when called by owner', async () => {
|
it('should change the token name when called by owner', async () => {
|
||||||
@@ -163,25 +160,25 @@ describe('TokenRegistry', () => {
|
|||||||
it('should throw if the name already exists', async () => {
|
it('should throw if the name already exists', async () => {
|
||||||
await tokenRegWrapper.addTokenAsync(token2, owner);
|
await tokenRegWrapper.addTokenAsync(token2, owner);
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }),
|
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if token does not exist', async () => {
|
it('should throw if token does not exist', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }),
|
tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setTokenSymbol', () => {
|
describe('setTokenSymbol', () => {
|
||||||
it('should throw when not called by owner', async () => {
|
it('should throw when not called by owner', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
|
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
|
||||||
from: notOwner,
|
from: notOwner,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the token symbol when called by owner', async () => {
|
it('should change the token symbol when called by owner', async () => {
|
||||||
@@ -203,28 +200,28 @@ describe('TokenRegistry', () => {
|
|||||||
it('should throw if the symbol already exists', async () => {
|
it('should throw if the symbol already exists', async () => {
|
||||||
await tokenRegWrapper.addTokenAsync(token2, owner);
|
await tokenRegWrapper.addTokenAsync(token2, owner);
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
|
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
|
||||||
from: owner,
|
from: owner,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if token does not exist', async () => {
|
it('should throw if token does not exist', async () => {
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, {
|
tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, {
|
||||||
from: owner,
|
from: owner,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('removeToken', () => {
|
describe('removeToken', () => {
|
||||||
it('should throw if not called by owner', async () => {
|
it('should throw if not called by owner', async () => {
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }),
|
tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove token metadata when called by owner', async () => {
|
it('should remove token metadata when called by owner', async () => {
|
||||||
@@ -241,17 +238,17 @@ describe('TokenRegistry', () => {
|
|||||||
|
|
||||||
it('should throw if token does not exist', async () => {
|
it('should throw if token does not exist', async () => {
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }),
|
tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if token at given index does not match address', async () => {
|
it('should throw if token at given index does not match address', async () => {
|
||||||
await tokenRegWrapper.addTokenAsync(token2, owner);
|
await tokenRegWrapper.addTokenAsync(token2, owner);
|
||||||
const incorrectIndex = new BigNumber(0);
|
const incorrectIndex = new BigNumber(0);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }),
|
tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -7,6 +7,7 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import { DummyERC20TokenContract } from '../src/contract_wrappers/generated/dummy_e_r_c20_token';
|
import { DummyERC20TokenContract } from '../src/contract_wrappers/generated/dummy_e_r_c20_token';
|
||||||
import { artifacts } from '../src/utils/artifacts';
|
import { artifacts } from '../src/utils/artifacts';
|
||||||
|
import { expectRevertOrAlwaysFailingTransaction } from '../src/utils/assertions';
|
||||||
import { chaiSetup } from '../src/utils/chai_setup';
|
import { chaiSetup } from '../src/utils/chai_setup';
|
||||||
import { constants } from '../src/utils/constants';
|
import { constants } from '../src/utils/constants';
|
||||||
import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
|
import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
|
||||||
@@ -93,11 +94,11 @@ describe('UnlimitedAllowanceToken', () => {
|
|||||||
await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }),
|
await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }),
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
|
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
|
||||||
from: spender,
|
from: spender,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if spender has insufficient allowance', async () => {
|
it('should throw if spender has insufficient allowance', async () => {
|
||||||
@@ -108,11 +109,11 @@ describe('UnlimitedAllowanceToken', () => {
|
|||||||
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
|
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
|
||||||
expect(isSpenderAllowanceInsufficient).to.be.true();
|
expect(isSpenderAllowanceInsufficient).to.be.true();
|
||||||
|
|
||||||
return expect(
|
return expectRevertOrAlwaysFailingTransaction(
|
||||||
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
|
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
|
||||||
from: spender,
|
from: spender,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true on a 0 value transfer', async () => {
|
it('should return true on a 0 value transfer', async () => {
|
||||||
|
Reference in New Issue
Block a user