aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-01 22:11:25 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-01 22:12:40 +0800
commit771c88ec791cb6bedf2ddd3418e89dec1581e326 (patch)
tree9b6d2a590d5a4d39cfd89c630bbeb774e75fc7d9
parenta1041348d5695ee3b84433e9874176e85543a4e0 (diff)
downloaddexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar.gz
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar.bz2
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar.lz
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar.xz
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.tar.zst
dexon-sol-tools-771c88ec791cb6bedf2ddd3418e89dec1581e326.zip
Revert "Add EXPIRED test"
This reverts commit d8e35c364ea94b606810b340fb02d8706e257c3c.
-rw-r--r--package.json2
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts3
-rw-r--r--src/types.ts1
-rw-r--r--test/exchange_wrapper_test.ts38
-rw-r--r--test/utils/order_factory.ts10
5 files changed, 20 insertions, 34 deletions
diff --git a/package.json b/package.json
index 8b472f2a9..8cef48c95 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"pretest:umd": "run-s clean build:*:dev",
"substitute_umd_bundle": "npm run remove_src_files_not_used_by_tests; shx mv _bundles/* lib/src",
"remove_src_files_not_used_by_tests": "find ./lib/src \\( -path ./lib/src/utils -o -path ./lib/src/schemas -o -path \"./lib/src/types.*\" \\) -prune -o -type f -print | xargs rm",
- "run_mocha": "mocha lib/test/**/*_test.js --timeout 3000"
+ "run_mocha": "mocha lib/test/**/*_test.js"
},
"config": {
"artifacts": "Proxy Exchange TokenRegistry Token Mintable EtherToken",
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 1232b969b..dbb427d2c 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -120,9 +120,6 @@ export class ExchangeWrapper extends ContractWrapper {
if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== senderAddress) {
throw new Error(FillOrderValidationErrs.NOT_A_TAKER);
}
- if (signedOrder.expirationUnixTimestampSec.lessThan(Date.now() / 1000)) {
- throw new Error(FillOrderValidationErrs.EXPIRED);
- }
}
private async getExchangeInstanceOrThrowAsync(): Promise<ExchangeContract> {
const contractInstance = await this.instantiateContractIfExistsAsync((ExchangeArtifacts as any));
diff --git a/src/types.ts b/src/types.ts
index 7c5e1825d..216026b3d 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -88,7 +88,6 @@ export type ExchangeContractErrs = keyof typeof ExchangeContractErrs;
export const FillOrderValidationErrs = strEnum([
'FILL_AMOUNT_IS_ZERO',
'NOT_A_TAKER',
- 'EXPIRED',
]);
export type FillOrderValidationErrs = keyof typeof FillOrderValidationErrs;
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index f929df149..c5cbc58be 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -107,9 +107,6 @@ describe('ExchangeWrapper', () => {
let tokens: Token[];
const addressBySymbol: {[symbol: string]: string} = {};
let networkId: number;
- let maker: string;
- let taker: string;
- const fillAmount = new BigNumber(5);
const setBalance = async (toAddress: string,
amountInBaseUnits: BigNumber.BigNumber|number,
tokenAddress: string) => {
@@ -129,43 +126,40 @@ describe('ExchangeWrapper', () => {
});
networkId = await promisify(web3.version.getNetwork)();
});
- beforeEach('get ready for fill', async () => {
- [maker, taker] = userAddresses;
- zeroEx.setDefaultAccount(taker);
- await setAllowance(maker, 5, addressBySymbol.MLN);
- await setBalance(taker, 5, addressBySymbol.GNT);
- await setAllowance(taker, 5, addressBySymbol.GNT);
- });
- afterEach('reset sender', () => {
- zeroEx.setDefaultAccount(userAddresses[0]);
- });
describe('failed fills', () => {
it('should throw when the fill amount is zero', async () => {
+ const maker = userAddresses[0];
+ const taker = userAddresses[0];
const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
5, addressBySymbol.MLN, 5, addressBySymbol.GNT);
+ const fillAmount = new BigNumber(0);
expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount))
.to.be.rejectedWith(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO);
});
it('should throw when sender is not a taker', async () => {
+ const maker = userAddresses[0];
+ const taker = userAddresses[1];
const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
5, addressBySymbol.MLN, 5, addressBySymbol.GNT);
- const notTaker = userAddresses[2];
- zeroEx.setDefaultAccount(notTaker);
+ const fillAmount = new BigNumber(5);
expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount))
.to.be.rejectedWith(FillOrderValidationErrs.NOT_A_TAKER);
});
- it('should throw when order is expired', async () => {
- const OLD_TIMESTAMP = new BigNumber(42);
- const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
- 5, addressBySymbol.MLN, 5, addressBySymbol.GNT, OLD_TIMESTAMP);
- expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount))
- .to.be.rejectedWith(FillOrderValidationErrs.EXPIRED);
- });
});
describe('successful fills', () => {
+ afterEach('reset default account', () => {
+ zeroEx.setDefaultAccount(userAddresses[0]);
+ });
it('should fill the valid order', async () => {
+ const maker = userAddresses[0];
+ const taker = userAddresses[1];
+ await setAllowance(maker, 5, addressBySymbol.MLN);
+ await setBalance(taker, 5, addressBySymbol.GNT);
+ await setAllowance(taker, 5, addressBySymbol.GNT);
const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker,
5, addressBySymbol.MLN, 5, addressBySymbol.GNT);
+ const fillAmount = new BigNumber(5);
+ zeroEx.setDefaultAccount(taker);
await zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount);
expect(await zeroEx.token.getBalanceAsync(addressBySymbol.MLN, taker)).to.be.bignumber.equal(5);
expect(await zeroEx.token.getBalanceAsync(addressBySymbol.GNT, taker)).to.be.bignumber.equal(0);
diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts
index c6c6ed927..e41e973ee 100644
--- a/test/utils/order_factory.ts
+++ b/test/utils/order_factory.ts
@@ -14,14 +14,10 @@ export const orderFactory = {
makerTokenAmount: BigNumber.BigNumber|number,
makerTokenAddress: string,
takerTokenAmount: BigNumber.BigNumber|number,
- takerTokenAddress: string,
- expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> {
+ takerTokenAddress: string): Promise<SignedOrder> {
// TODO refactor and check
const exchangeAddress: string = (ExchangeArtifacts as any).networks[networkId].address;
- const INF_TIMESTAMP = new BigNumber(2524604400);
- expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSec) ?
- INF_TIMESTAMP :
- expirationUnixTimestampSec;
+ const INF_TIMESTAMP = 2524604400;
const order = {
maker,
taker,
@@ -33,7 +29,7 @@ export const orderFactory = {
takerTokenAddress,
salt: ZeroEx.generatePseudoRandomSalt(),
feeRecipient: constants.NULL_ADDRESS,
- expirationUnixTimestampSec,
+ expirationUnixTimestampSec: new BigNumber(INF_TIMESTAMP),
};
const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order);
const ecSignature = await zeroEx.signOrderHashAsync(orderHash);