Browse Source

lnbase: rename methods, fix tests

regtest_lnd
ThomasV 6 years ago
committed by SomberNight
parent
commit
19b27713f3
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 14
      electrum/lnbase.py
  2. 6
      electrum/tests/test_lnbase.py

14
electrum/lnbase.py

@ -706,7 +706,7 @@ class Peer(PrintError):
chan.config[LOCAL]=chan.config[LOCAL]._replace(
ctn=remote_ctn,
)
self.revoke(chan)
self.send_revoke_and_ack(chan)
else:
self.print_error("expected local ctn {}, got {}".format(chan.config[LOCAL].ctn, local_ctn))
# TODO iff their ctn is lower than ours, we should force close instead
@ -968,15 +968,15 @@ class Peer(PrintError):
async def send_and_revoke(self, chan: Channel):
""" generic channel update flow """
self.send_commitment(chan)
await self.receive_revoke(chan)
await self.receive_revoke_and_ack(chan)
await self.receive_commitment(chan)
self.revoke(chan)
self.send_revoke_and_ack(chan)
async def receive_and_revoke(self, chan: Channel):
await self.receive_commitment(chan)
self.revoke(chan)
self.send_revoke_and_ack(chan)
self.send_commitment(chan)
await self.receive_revoke(chan)
await self.receive_revoke_and_ack(chan)
async def pay(self, route: List['RouteEdge'], chan: Channel, amount_msat: int,
payment_hash: bytes, min_final_cltv_expiry: int):
@ -1004,12 +1004,12 @@ class Peer(PrintError):
await self.send_and_revoke(chan)
return UpdateAddHtlc(**htlc, htlc_id=htlc_id)
async def receive_revoke(self, chan: Channel):
async def receive_revoke_and_ack(self, chan: Channel):
revoke_and_ack_msg = await self.revoke_and_ack[chan.channel_id].get()
chan.receive_revocation(RevokeAndAck(revoke_and_ack_msg["per_commitment_secret"], revoke_and_ack_msg["next_per_commitment_point"]))
self.lnworker.save_channel(chan)
def revoke(self, chan: Channel):
def send_revoke_and_ack(self, chan: Channel):
rev, _ = chan.revoke_current_commitment()
self.lnworker.save_channel(chan)
self.send_message("revoke_and_ack",

6
electrum/tests/test_lnbase.py

@ -96,6 +96,12 @@ class MockLNWorker:
def channels_for_peer(self, pubkey):
return self.channels
def get_channel_by_short_id(self, short_channel_id):
with self.lock:
for chan in self.channels.values():
if chan.short_channel_id == short_channel_id:
return chan
def save_channel(self, chan):
print("Ignoring channel save")

Loading…
Cancel
Save