aboutsummaryrefslogtreecommitdiff
path: root/src/types-test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-07-05 02:09:07 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-07-05 02:09:07 +0200
commit075fe28f74c9545a2d2d144a02abb134430d1352 (patch)
treebd14f82260806d4603adf26121685b376699fdd7 /src/types-test.ts
parenta4edc3b17f27de5866e11d04a1fc9bbd4d657867 (diff)
downloadwallet-core-075fe28f74c9545a2d2d144a02abb134430d1352.tar.xz
avoid floating point imprecision with amounts
Diffstat (limited to 'src/types-test.ts')
-rw-r--r--src/types-test.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/types-test.ts b/src/types-test.ts
index d65daeade..626063eba 100644
--- a/src/types-test.ts
+++ b/src/types-test.ts
@@ -63,6 +63,15 @@ test("amount parsing", (t) => {
});
+test("amount stringification", (t) => {
+ t.is(Amounts.toString(amt(4, 94000000, "TESTKUDOS")), "TESTKUDOS:4.94");
+ t.is(Amounts.toString(amt(0, 10000000, "TESTKUDOS")), "TESTKUDOS:0.1");
+ t.is(Amounts.toString(amt(0, 1, "TESTKUDOS")), "TESTKUDOS:0.00000001");
+ t.is(Amounts.toString(amt(5, 0, "TESTKUDOS")), "TESTKUDOS:5");
+ t.pass();
+});
+
+
test("contract terms validation", (t) => {
const c = {
H_wire: "123",