From: Chris Duncan Date: Sun, 14 Sep 2025 06:56:20 +0000 (-0700) Subject: Add test for fractional nano amounts. X-Git-Tag: v0.10.5~14^2~28 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=23158ed5c074e55ef01c3386e93b2d1e4b30411d;p=libnemo.git Add test for fractional nano amounts. --- diff --git a/test/test.tools.mjs b/test/test.tools.mjs index d802209..cb7e312 100644 --- a/test/test.tools.mjs +++ b/test/test.tools.mjs @@ -42,11 +42,21 @@ await Promise.all([ assert.equal(result, '1000000000000000000000000000000') }) + await test("convert fractional nano to raw", async () => { + const result = Tools.convert("0.05", "NANO", "RAW") + assert.equal(result, "50000000000000000000000000000") + }) + await test('convert raw to nano', async () => { const result = Tools.convert('1000000000000000000000000000000', 'RAW', 'NANO') assert.equal(result, '1') }) + await test("convert raw to fractional nano", async () => { + const result = Tools.convert("50000000000000000000000000000", "RAW", "NANO") + assert.equal(result, "0.05") + }) + await test('convert 1 raw to 10^-29 nano', async () => { const result = Tools.convert('1', 'RAW', 'NANO') assert.equal(result, '0.000000000000000000000000000001')