electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1520338f37ad601c328df087bdf7bc7f0025ce95
parent 521fadb8cb565ff683a1c7a06092da5277a67b94
Author: Janus <ysangkok@gmail.com>
Date:   Wed,  7 Nov 2018 18:00:28 +0100

fix ln tests

Diffstat:
Melectrum/lnchan.py | 2+-
Melectrum/tests/test_bolt11.py | 4++--
Melectrum/tests/test_lnbase.py | 15+++++++++++++++
Melectrum/tests/test_lnchan.py | 2+-
4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/electrum/lnchan.py b/electrum/lnchan.py @@ -149,7 +149,7 @@ class Channel(PrintError): def __init__(self, state, name = None, payment_completed : Optional[Callable[[HTLCOwner, UpdateAddHtlc, bytes], None]] = None): self.preimages = {} if not payment_completed: - payment_completed = lambda x: None + payment_completed = lambda x, y, z: None self.payment_completed = payment_completed assert 'local_state' not in state self.config = {} diff --git a/electrum/tests/test_bolt11.py b/electrum/tests/test_bolt11.py @@ -93,9 +93,9 @@ class TestBolt11(unittest.TestCase): assert lnaddr.pubkey.serialize() == PUBKEY def test_min_final_cltv_expiry_decoding(self): - self.assertEquals(144, lndecode("lnsb500u1pdsgyf3pp5nmrqejdsdgs4n9ukgxcp2kcq265yhrxd4k5dyue58rxtp5y83s3qdqqcqzystrggccm9yvkr5yqx83jxll0qjpmgfg9ywmcd8g33msfgmqgyfyvqhku80qmqm8q6v35zvck2y5ccxsz5avtrauz8hgjj3uahppyq20qp6dvwxe", expected_hrp="sb").get_min_final_cltv_expiry()) + self.assertEqual(144, lndecode("lnsb500u1pdsgyf3pp5nmrqejdsdgs4n9ukgxcp2kcq265yhrxd4k5dyue58rxtp5y83s3qdqqcqzystrggccm9yvkr5yqx83jxll0qjpmgfg9ywmcd8g33msfgmqgyfyvqhku80qmqm8q6v35zvck2y5ccxsz5avtrauz8hgjj3uahppyq20qp6dvwxe", expected_hrp="sb").get_min_final_cltv_expiry()) def test_min_final_cltv_expiry_roundtrip(self): lnaddr = LnAddr(RHASH, amount=Decimal('0.001'), tags=[('d', '1 cup coffee'), ('x', 60), ('c', 150)]) invoice = lnencode(lnaddr, PRIVKEY) - self.assertEquals(150, lndecode(invoice).get_min_final_cltv_expiry()) + self.assertEqual(150, lndecode(invoice).get_min_final_cltv_expiry()) diff --git a/electrum/tests/test_lnbase.py b/electrum/tests/test_lnbase.py @@ -61,6 +61,19 @@ class MockNetwork: if self.tx_queue: await self.tx_queue.put(tx) +class MockStorage: + def put(self, key, value): + pass + + def get(self, key, default=None): + pass + + def write(self): + pass + +class MockWallet: + storage = MockStorage() + class MockLNWorker: def __init__(self, remote_keypair, local_keypair, chan, tx_queue): self.chan = chan @@ -69,6 +82,8 @@ class MockLNWorker: self.network = MockNetwork(tx_queue) self.channels = {self.chan.channel_id: self.chan} self.invoices = {} + self.paying = {} + self.wallet = MockWallet() @property def lock(self): diff --git a/electrum/tests/test_lnchan.py b/electrum/tests/test_lnchan.py @@ -193,7 +193,7 @@ class TestChannel(unittest.TestCase): bob_idx = self.bob_channel.add_htlc(self.htlc_dict) alice_idx = self.alice_channel.receive_htlc(self.htlc_dict) self.alice_channel.receive_new_commitment(*self.bob_channel.sign_next_commitment()) - self.assertEquals(len(self.alice_channel.pending_remote_commitment.outputs()), 3) + self.assertEqual(len(self.alice_channel.pending_remote_commitment.outputs()), 3) def test_SimpleAddSettleWorkflow(self): alice_channel, bob_channel = self.alice_channel, self.bob_channel