Browse Source

fix ln tests

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 6 years ago
committed by ThomasV
parent
commit
1520338f37
  1. 2
      electrum/lnchan.py
  2. 4
      electrum/tests/test_bolt11.py
  3. 15
      electrum/tests/test_lnbase.py
  4. 2
      electrum/tests/test_lnchan.py

2
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 = {}

4
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())

15
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):

2
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

Loading…
Cancel
Save