aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2017-11-21 10:04:36 +0800
committerJacob Evans <jacob@dekz.net>2017-11-21 10:04:36 +0800
commitbbcee8dfa735ae8261b29cd917a99c97c551ed5d (patch)
tree974f6167be8bff3164af3a50ef863d02165fb643 /packages/0x.js/test
parent5b8f84f59a5996458d3da5faf0fc7c3fa6c93ee6 (diff)
downloaddexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar.gz
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar.bz2
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar.lz
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar.xz
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.tar.zst
dexon-sol-tools-bbcee8dfa735ae8261b29cd917a99c97c551ed5d.zip
Move to base units
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r--packages/0x.js/test/remaining_fillable_calculator_test.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/0x.js/test/remaining_fillable_calculator_test.ts b/packages/0x.js/test/remaining_fillable_calculator_test.ts
index 7dea660b8..f1821551f 100644
--- a/packages/0x.js/test/remaining_fillable_calculator_test.ts
+++ b/packages/0x.js/test/remaining_fillable_calculator_test.ts
@@ -5,6 +5,7 @@ import { chaiSetup } from './utils/chai_setup';
import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fillable_calculator';
import { SignedOrder, ECSignature } from '../src/types';
import { TokenUtils } from './utils/token_utils';
+import { ZeroEx } from '../src/0x';
chaiSetup.configure();
const expect = chai.expect;
@@ -26,7 +27,12 @@ describe.only('RemainingFillableCalculator', () => {
const signature: ECSignature = { v: 27, r: '', s: ''};
before(async () => {
[makerToken, takerToken, zrxToken] = ['0x1', '0x2', '0x3'];
- [makerAmount, takerAmount, makerFee] = [new BigNumber(50), new BigNumber(5), new BigNumber(1)];
+ [makerAmount, takerAmount, makerFee] = [ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
+ ZeroEx.toBaseUnitAmount(new BigNumber(5), 18),
+ ZeroEx.toBaseUnitAmount(new BigNumber(1), 18)];
+ [transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount] = [
+ ZeroEx.toBaseUnitAmount(new BigNumber(50), 18),
+ ZeroEx.toBaseUnitAmount(new BigNumber(5), 18)];
});
function buildSignedOrder(): SignedOrder {
return { ecSignature: signature,
@@ -45,9 +51,7 @@ describe.only('RemainingFillableCalculator', () => {
}
it('calculates the correct amount when partially filled and funds available', () => {
signedOrder = buildSignedOrder();
- remainingMakerTokenAmount = new BigNumber(1);
- transferrableMakerTokenAmount = new BigNumber(100);
- transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
+ remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
calculator = new RemainingFillableCalculator(signedOrder, zrxToken,
transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
@@ -55,7 +59,6 @@ describe.only('RemainingFillableCalculator', () => {
describe('Maker token is NOT ZRX', () => {
it('calculates the amount to be 0 when all fee funds move', () => {
signedOrder = buildSignedOrder();
- transferrableMakerTokenAmount = new BigNumber(100);
transferrableMakerFeeTokenAmount = zero;
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
calculator = new RemainingFillableCalculator(signedOrder, zrxToken,
@@ -69,9 +72,7 @@ describe.only('RemainingFillableCalculator', () => {
});
it('calculates the correct amount when partially filled and funds available', () => {
signedOrder = buildSignedOrder();
- transferrableMakerTokenAmount = new BigNumber(100);
- transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
- remainingMakerTokenAmount = new BigNumber(1);
+ remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
calculator = new RemainingFillableCalculator(signedOrder, zrxToken,
transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
@@ -79,7 +80,7 @@ describe.only('RemainingFillableCalculator', () => {
it('calculates the amount to be 0 when all fee funds move', () => {
signedOrder = buildSignedOrder();
transferrableMakerTokenAmount = zero;
- transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
+ transferrableMakerFeeTokenAmount = zero;
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
calculator = new RemainingFillableCalculator(signedOrder, zrxToken,
transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);