Skip to content

Commit

Permalink
pyln: failing test msat from float str
Browse files Browse the repository at this point in the history
Currently we are not able to create pyln Millisatoshi from floats, e.g.:
 - "0.01btc"
 - "0.1sat"
 - ...

This adds a test that is currently expected to fail because of this bug.

Changelog-None
  • Loading branch information
m-schmoock committed Nov 30, 2020
1 parent 32de621 commit 59bccae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contrib/pyln-client/tests/test_units.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pyln.client import Millisatoshi
import pytest


def test_to_approx_str():
Expand Down Expand Up @@ -34,3 +35,13 @@ def test_to_approx_str():
assert amount.to_approx_str() == "12btc"
amount = Millisatoshi('1200000000sat')
assert amount.to_approx_str(1) == "12btc" # note: no rounding


@pytest.mark.xfail
def test_floats():
amount = Millisatoshi("0.01btc")
assert amount.to_satoshi() == 10**6
amount = Millisatoshi("0.1sat")
assert int(amount) == 100
with pytest.raises(ValueError):
amount = Millisatoshi("0.1msat")

0 comments on commit 59bccae

Please sign in to comment.