aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/fill_scenarios.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts
index 3b66937e6..17c2dbeba 100644
--- a/test/utils/fill_scenarios.ts
+++ b/test/utils/fill_scenarios.ts
@@ -32,4 +32,24 @@ export class FillScenarios {
this.zeroEx.setTransactionSenderAccount(transactionSenderAccount as string);
return signedOrder;
}
+ public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
+ takerAddress: string, fillableAmount: BigNumber.BigNumber,
+ partialFillAmount: BigNumber.BigNumber) {
+ const prevSenderAccount = await this.zeroEx.getTransactionSenderAccountIfExistsAsync();
+ const [makerAddress] = this.userAddresses;
+ await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount);
+ await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount);
+ await this.zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, fillableAmount);
+
+ const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress,
+ takerAddress, fillableAmount, makerTokenAddress, fillableAmount, takerTokenAddress);
+
+ this.zeroEx.setTransactionSenderAccount(takerAddress);
+ const shouldCheckTransfer = false;
+ await this.zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer);
+
+ // Re-set sender account so as to avoid introducing side-effects
+ this.zeroEx.setTransactionSenderAccount(prevSenderAccount as string);
+ return signedOrder;
+ }
}