From 565dc95a8e6fc933be0e15d8510fce4b4ff4e21d Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Wed, 2 Dec 2020 12:30:46 +0100 Subject: [PATCH] pyln: fix msat float multiplication --- contrib/pyln-client/pyln/client/lightning.py | 2 +- contrib/pyln-client/tests/test_units.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index febc4b944..e87a57c05 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -177,7 +177,7 @@ class Millisatoshi: return Millisatoshi(int(self) - int(other)) def __mul__(self, other: int) -> 'Millisatoshi': - return Millisatoshi(self.millisatoshis * other) + return Millisatoshi(int(self.millisatoshis * other)) def __truediv__(self, other: Union[int, float]) -> 'Millisatoshi': return Millisatoshi(int(self.millisatoshis / other)) diff --git a/contrib/pyln-client/tests/test_units.py b/contrib/pyln-client/tests/test_units.py index 582f918d9..bc612a6c7 100644 --- a/contrib/pyln-client/tests/test_units.py +++ b/contrib/pyln-client/tests/test_units.py @@ -93,7 +93,6 @@ def test_zero(): assert int(amount) == 0 -@pytest.mark.xfail def test_round_zero(): # everything below 1msat should round down to zero amount = Millisatoshi("1msat") * 0.9 @@ -151,7 +150,6 @@ def test_round_zero(): assert int(amount) == 0 -@pytest.mark.xfail def test_round_down(): # sub msat significatns should be floored amount = Millisatoshi("2msat") * 0.9