aboutsummaryrefslogtreecommitdiffstats
path: root/test/order_validation_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-09-26 22:07:42 +0800
committerGitHub <noreply@github.com>2017-09-26 22:07:42 +0800
commit949fc2fc821f8e596a2f9c972db70e04d41bb0f6 (patch)
treed25a045b3b5d7cba28c8f8c919124f178587bf78 /test/order_validation_test.ts
parent3c40526bffcccbad2a64f92f69f3b6ec63946c88 (diff)
parent5f7afce49d0c2367fc2a7b2f45334d64469ef32f (diff)
downloaddexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar.gz
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar.bz2
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar.lz
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar.xz
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.tar.zst
dexon-sol-tools-949fc2fc821f8e596a2f9c972db70e04d41bb0f6.zip
Merge pull request #170 from 0xProject/addOrderValidation
Add validateOrderFillableOrThrowAsync Method
Diffstat (limited to 'test/order_validation_test.ts')
-rw-r--r--test/order_validation_test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/order_validation_test.ts b/test/order_validation_test.ts
index 9a621555c..f625433eb 100644
--- a/test/order_validation_test.ts
+++ b/test/order_validation_test.ts
@@ -54,6 +54,46 @@ describe('OrderValidation', () => {
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
+ describe('validateOrderFillableOrThrowAsync', () => {
+ it('should succeed if the order is fillable', async () => {
+ const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ );
+ await zeroEx.exchange.validateOrderFillableOrThrowAsync(
+ signedOrder,
+ );
+ });
+ it('should succeed if the order is asymmetric and fillable', async () => {
+ const makerFillableAmount = fillableAmount;
+ const takerFillableAmount = fillableAmount.minus(4);
+ const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
+ makerFillableAmount, takerFillableAmount,
+ );
+ await zeroEx.exchange.validateOrderFillableOrThrowAsync(
+ signedOrder,
+ );
+ });
+ it('should throw when the order is fully filled or cancelled', async () => {
+ const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ );
+ await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
+ return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(
+ signedOrder,
+ )).to.be.rejectedWith(ExchangeContractErrs.OrderRemainingFillAmountZero);
+ });
+ it('should throw when order is expired', async () => {
+ const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
+ const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
+ fillableAmount, expirationInPast,
+ );
+ return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(
+ signedOrder,
+ )).to.be.rejectedWith(ExchangeContractErrs.OrderFillExpired);
+ });
+ });
describe('validateFillOrderAndThrowIfInvalidAsync', () => {
it('should throw when the fill amount is zero', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(