mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
fix ln tests
This commit is contained in:
parent
ce1ff477d0
commit
cedf1b5433
4 changed files with 19 additions and 4 deletions
|
@ -149,7 +149,7 @@ class Channel(PrintError):
|
||||||
def __init__(self, state, name = None, payment_completed : Optional[Callable[[HTLCOwner, UpdateAddHtlc, bytes], None]] = None):
|
def __init__(self, state, name = None, payment_completed : Optional[Callable[[HTLCOwner, UpdateAddHtlc, bytes], None]] = None):
|
||||||
self.preimages = {}
|
self.preimages = {}
|
||||||
if not payment_completed:
|
if not payment_completed:
|
||||||
payment_completed = lambda x: None
|
payment_completed = lambda x, y, z: None
|
||||||
self.payment_completed = payment_completed
|
self.payment_completed = payment_completed
|
||||||
assert 'local_state' not in state
|
assert 'local_state' not in state
|
||||||
self.config = {}
|
self.config = {}
|
||||||
|
|
|
@ -93,9 +93,9 @@ class TestBolt11(unittest.TestCase):
|
||||||
assert lnaddr.pubkey.serialize() == PUBKEY
|
assert lnaddr.pubkey.serialize() == PUBKEY
|
||||||
|
|
||||||
def test_min_final_cltv_expiry_decoding(self):
|
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):
|
def test_min_final_cltv_expiry_roundtrip(self):
|
||||||
lnaddr = LnAddr(RHASH, amount=Decimal('0.001'), tags=[('d', '1 cup coffee'), ('x', 60), ('c', 150)])
|
lnaddr = LnAddr(RHASH, amount=Decimal('0.001'), tags=[('d', '1 cup coffee'), ('x', 60), ('c', 150)])
|
||||||
invoice = lnencode(lnaddr, PRIVKEY)
|
invoice = lnencode(lnaddr, PRIVKEY)
|
||||||
self.assertEquals(150, lndecode(invoice).get_min_final_cltv_expiry())
|
self.assertEqual(150, lndecode(invoice).get_min_final_cltv_expiry())
|
||||||
|
|
|
@ -61,6 +61,19 @@ class MockNetwork:
|
||||||
if self.tx_queue:
|
if self.tx_queue:
|
||||||
await self.tx_queue.put(tx)
|
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:
|
class MockLNWorker:
|
||||||
def __init__(self, remote_keypair, local_keypair, chan, tx_queue):
|
def __init__(self, remote_keypair, local_keypair, chan, tx_queue):
|
||||||
self.chan = chan
|
self.chan = chan
|
||||||
|
@ -69,6 +82,8 @@ class MockLNWorker:
|
||||||
self.network = MockNetwork(tx_queue)
|
self.network = MockNetwork(tx_queue)
|
||||||
self.channels = {self.chan.channel_id: self.chan}
|
self.channels = {self.chan.channel_id: self.chan}
|
||||||
self.invoices = {}
|
self.invoices = {}
|
||||||
|
self.paying = {}
|
||||||
|
self.wallet = MockWallet()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lock(self):
|
def lock(self):
|
||||||
|
|
|
@ -193,7 +193,7 @@ class TestChannel(unittest.TestCase):
|
||||||
bob_idx = self.bob_channel.add_htlc(self.htlc_dict)
|
bob_idx = self.bob_channel.add_htlc(self.htlc_dict)
|
||||||
alice_idx = self.alice_channel.receive_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.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):
|
def test_SimpleAddSettleWorkflow(self):
|
||||||
alice_channel, bob_channel = self.alice_channel, self.bob_channel
|
alice_channel, bob_channel = self.alice_channel, self.bob_channel
|
||||||
|
|
Loading…
Add table
Reference in a new issue