commit 6dfcfb85a82532bb66cd5f3647e7ae98c254ab3f
parent 1d05b2bbe1cb5ebc283e9ddc991245fc8ff20ec9
Author: William Casarin <jb55@jb55.com>
Date: Sat, 23 Dec 2017 15:34:44 -0800
fiat: fix some failing tests + conversions
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/num.c b/num.c
@@ -65,7 +65,7 @@ num_to_msat(struct num *num) {
anyval = g_other.type == TYPE_FLOAT?
g_other.floatval : (double)g_other.intval;
case UNIT_BTC:
- return (val/anyval) * BTC;
+ return val * BTC*(1.0/anyval);
case UNIT_NONE:
assert(!"got UNIT_NONE in num_to_msat");
}
diff --git a/test/tests.csv b/test/tests.csv
@@ -25,6 +25,8 @@ simple fiat test with bits,--price 15000 --bits,1 fiat,66.66666 bits
1 BTC is 1000000 other,--price 1000000 --other,100 mbtc,100000 other
1 other @15k is 66.66666 bits,--price 15000 --bits,1 other,66.66666 bits
1 btc/2 should work,--btc -n,1 btc / 2,0.5
+60 usd at 25000 in bits,--bits --price 25000,60 fiat,2400 bits
# failing
-1/2 btc should work,--btc,1/2 btc,0.5
1 BTC is 15000 usd,--price 15000 --usd,1 btc,15000 USD
+# needs implementation
+1/2 btc should work,--btc,1/2 btc,0.5