aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-02 01:47:22 +0800
committerFabio Berger <me@fabioberger.com>2017-06-02 01:47:22 +0800
commita1be87058536f5ab10c68c570c1b9994defe52b1 (patch)
tree935878b66d6588e4614efe32ac7052dcdb0bb447 /test/utils
parentc42877327e59f983a83c7221f1bec5b31addf5a7 (diff)
downloaddexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar.gz
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar.bz2
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar.lz
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar.xz
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.tar.zst
dexon-sol-tools-a1be87058536f5ab10c68c570c1b9994defe52b1.zip
Create a FillsScenario utils module and use it in the fillOrder tests
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/fill_scenarios.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts
new file mode 100644
index 000000000..8447c8c15
--- /dev/null
+++ b/test/utils/fill_scenarios.ts
@@ -0,0 +1,29 @@
+import * as BigNumber from 'bignumber.js';
+import {ZeroEx} from '../../src/0x.js';
+import {Token, SignedOrder} from '../../src/types';
+import {orderFactory} from '../utils/order_factory';
+
+export class FillScenarios {
+ private zeroEx: ZeroEx;
+ private userAddresses: string[];
+ private tokens: Token[];
+ constructor(zeroEx: ZeroEx, userAddresses: string[], tokens: Token[]) {
+ this.zeroEx = zeroEx;
+ this.userAddresses = userAddresses;
+ this.tokens = tokens;
+ }
+ public async createAFillableSignedOrderAsync(takerAddress: string, fillableAmount: BigNumber.BigNumber,
+ expirationUnixTimestampSec?: BigNumber.BigNumber):
+ Promise<SignedOrder> {
+ const [makerAddress] = this.userAddresses;
+ const [makerToken, takerToken] = this.tokens;
+ await this.zeroEx.token.setProxyAllowanceAsync(makerToken.address, makerAddress, fillableAmount);
+ await this.zeroEx.token.transferAsync(takerToken.address, makerAddress, takerAddress, fillableAmount);
+ await this.zeroEx.token.setProxyAllowanceAsync(takerToken.address, takerAddress, fillableAmount);
+
+ const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress,
+ takerAddress, fillableAmount, makerToken.address, fillableAmount, takerToken.address,
+ expirationUnixTimestampSec);
+ return signedOrder;
+ }
+}