aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-12-21 16:34:50 +0800
committerFabio Berger <me@fabioberger.com>2017-12-21 16:34:50 +0800
commitb94d13b413c9eef7b4afd7244cbc48167239f629 (patch)
treeff9583f69f38e225ee69d7521fd6d82745129770 /packages/0x.js/test
parent85e16c1233fc2c7020c2556cd79ac7d53cee4c98 (diff)
downloaddexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar.gz
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar.bz2
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar.lz
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar.xz
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.tar.zst
dexon-sol-tools-b94d13b413c9eef7b4afd7244cbc48167239f629.zip
Refactor toBaseUnitAmount so that it throws if user supplies unitAmount with too many decimals
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r--packages/0x.js/test/0x.js_test.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 9bf504909..245946a89 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -136,6 +136,12 @@ describe('ZeroEx library', () => {
const expectedUnitAmount = new BigNumber(1000000000);
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
});
+ it('should throw if unitAmount has more decimals then specified as the max decimal precision', () => {
+ const unitAmount = new BigNumber(0.823091);
+ const decimals = 5;
+ expect(() => ZeroEx.toBaseUnitAmount(unitAmount, decimals))
+ .to.throw('Invalid unit amount: 0.823091 - Too many decimal places');
+ });
});
describe('#getOrderHashHex', () => {
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';