IPC removed, replaced by WS

This commit is contained in:
Luis Fernando Molina committed 2020-04-06 08:33:07 +02:00
1 parent ba4217fb24
commit 656c193511
503 files changed
+28128 -34498

No files matched your search

+61 -2
View File
@@ -1,8 +1,49 @@
'use strict'
const { numberToString, decimalToPrecision, ROUND, TRUNCATE, DECIMAL_PLACES, TICK_SIZE, PAD_WITH_ZERO, SIGNIFICANT_DIGITS } = require ('../../../../ccxt');
const { numberToString, decimalToPrecision, ROUND, TRUNCATE, DECIMAL_PLACES, TICK_SIZE, PAD_WITH_ZERO, SIGNIFICANT_DIGITS, toWei, fromWei } = require ('../../../../ccxt');
const assert = require ('assert');
// ----------------------------------------------------------------------------
// toWei / fromWei
assert (toWei (1, 18) === '1000000000000000000');
assert (toWei (1, 17) === '100000000000000000');
assert (toWei (1, 16) === '10000000000000000');
assert (toWei ('1', 18) === '1000000000000000000');
assert (toWei ('1', 17) === '100000000000000000');
assert (toWei ('1', 16) === '10000000000000000');
assert (toWei (0, 18) === '0');
assert (toWei (1, 0) === '1');
assert (toWei (1, 1) === '10');
assert (toWei (1.3, 18) === '1300000000000000000');
assert (toWei ('1.3', 18) === '1300000000000000000');
assert (toWei (1.999, 17) === '199900000000000000');
assert (toWei ('1.999', 17) === '199900000000000000');
assert (toWei ('0.1', 18) === '100000000000000000');
assert (toWei ('0.01', 18) === '10000000000000000');
assert (toWei ('0.001', 18) === '1000000000000000');
assert (toWei (0.1, 18) === '100000000000000000');
assert (toWei (0.01, 18) === '10000000000000000');
assert (toWei (0.001, 18) === '1000000000000000');
// let us test that we get the inverse for all these test
assert (fromWei ('1000000000000000000', 18) === 1.0);
assert (fromWei ('100000000000000000', 17) === 1.0);
assert (fromWei ('10000000000000000', 16) === 1.0);
assert (fromWei (1000000000000000000, 18) === 1.0);
assert (fromWei (100000000000000000, 17) === 1.0);
assert (fromWei (10000000000000000, 16) === 1.0);
assert (fromWei ('1300000000000000000', 18) === 1.3);
assert (fromWei (1300000000000000000, 18) === 1.3);
assert (fromWei ('199900000000000000', 17) === 1.999);
assert (fromWei (199900000000000000, 17) === 1.999);
assert (fromWei ('100000000000000000', 18) === 0.1);
assert (fromWei ('10000000000000000', 18) === 0.01);
assert (fromWei ('1000000000000000', 18) === 0.001);
assert (fromWei (100000000000000000, 18) === 0.1);
assert (fromWei (10000000000000000, 18) === 0.01);
assert (fromWei (1000000000000000, 18) === 0.001);
// ----------------------------------------------------------------------------
// numberToString
@@ -17,7 +58,7 @@ assert (numberToString (7.9e27) === '7900000000000000000000000000');
assert (numberToString (-12.345) === '-12.345');
assert (numberToString (12.345) === '12.345');
assert (numberToString (0) === '0');
// this line breaks the test
// the following line breaks the test
// see https://github.com/ccxt/ccxt/issues/5744
// assert (numberToString (0.00000001) === '0.00000001');
@@ -157,6 +198,24 @@ assert (decimalToPrecision ('-0.000123456789', ROUND, 0.00000012, TICK_SIZE) ===
assert (decimalToPrecision ('-0.000123456789', TRUNCATE, 0.00000012, TICK_SIZE) === '-0.00012336');
assert (decimalToPrecision ('-165', TRUNCATE, 110, TICK_SIZE) === '-110');
assert (decimalToPrecision ('-165', ROUND, 110, TICK_SIZE) === '-220');
assert (decimalToPrecision ('-1650', TRUNCATE, 1100, TICK_SIZE) === '-1100');
assert (decimalToPrecision ('-1650', ROUND, 1100, TICK_SIZE) === '-2200');
assert (decimalToPrecision ('0.0006', TRUNCATE, 0.0001, TICK_SIZE) === '0.0006');
assert (decimalToPrecision ('-0.0006', TRUNCATE, 0.0001, TICK_SIZE) === '-0.0006');
assert (decimalToPrecision ('0.6', TRUNCATE, 0.2, TICK_SIZE) === '0.6');
assert (decimalToPrecision ('-0.6', TRUNCATE, 0.2, TICK_SIZE) === '-0.6');
assert (decimalToPrecision ('1.2', ROUND, 0.4, TICK_SIZE) === '1.2');
assert (decimalToPrecision ('-1.2', ROUND, 0.4, TICK_SIZE) === '-1.2');
assert (decimalToPrecision ('1.2', ROUND, 0.02, TICK_SIZE) === '1.2');
assert (decimalToPrecision ('-1.2', ROUND, 0.02, TICK_SIZE) === '-1.2');
assert (decimalToPrecision ('44', ROUND, 4.4, TICK_SIZE) === '44');
assert (decimalToPrecision ('-44', ROUND, 4.4, TICK_SIZE) === '-44');
assert (decimalToPrecision ('44.00000001', ROUND, 4.4, TICK_SIZE) === '44');
assert (decimalToPrecision ('-44.00000001', ROUND, 4.4, TICK_SIZE) === '-44');
// https://github.com/ccxt/ccxt/issues/6731
assert (decimalToPrecision ('20', TRUNCATE, 0.00000001, TICK_SIZE) === '20');
// ----------------------------------------------------------------------------
// testDecimalToPrecisionNegativeNumbers