ln gossip: don't put own channels into db; always pass them to fn calls
Previously we would put fake chan announcement and fake outgoing chan upd for own channels into db (to make path finding work). See Peer.add_own_channel(). Now, instead of above, we pass a "my_channels" param to the relevant ChannelDB methods.
This commit is contained in:
@@ -18,7 +18,7 @@ from electrum.lnpeer import Peer
|
||||
from electrum.lnutil import LNPeerAddr, Keypair, privkey_to_pubkey
|
||||
from electrum.lnutil import LightningPeerConnectionClosed, RemoteMisbehaving
|
||||
from electrum.lnutil import PaymentFailure, LnLocalFeatures
|
||||
from electrum.lnchannel import channel_states, peer_states
|
||||
from electrum.lnchannel import channel_states, peer_states, Channel
|
||||
from electrum.lnrouter import LNPathFinder
|
||||
from electrum.channel_db import ChannelDB
|
||||
from electrum.lnworker import LNWallet, NoPathFound
|
||||
@@ -77,7 +77,7 @@ class MockWallet:
|
||||
return False
|
||||
|
||||
class MockLNWallet:
|
||||
def __init__(self, remote_keypair, local_keypair, chan, tx_queue):
|
||||
def __init__(self, remote_keypair, local_keypair, chan: 'Channel', tx_queue):
|
||||
self.remote_keypair = remote_keypair
|
||||
self.node_keypair = local_keypair
|
||||
self.network = MockNetwork(tx_queue)
|
||||
@@ -88,6 +88,8 @@ class MockLNWallet:
|
||||
self.localfeatures = LnLocalFeatures(0)
|
||||
self.localfeatures |= LnLocalFeatures.OPTION_DATA_LOSS_PROTECT_OPT
|
||||
self.pending_payments = defaultdict(asyncio.Future)
|
||||
chan.lnworker = self
|
||||
chan.node_id = remote_keypair.pubkey
|
||||
|
||||
def get_invoice_status(self, key):
|
||||
pass
|
||||
@@ -127,6 +129,7 @@ class MockLNWallet:
|
||||
_pay_to_route = LNWallet._pay_to_route
|
||||
force_close_channel = LNWallet.force_close_channel
|
||||
get_first_timestamp = lambda self: 0
|
||||
payment_completed = LNWallet.payment_completed
|
||||
|
||||
class MockTransport:
|
||||
def __init__(self, name):
|
||||
@@ -264,7 +267,7 @@ class TestPeer(ElectrumTestCase):
|
||||
pay_req = self.prepare_invoice(w2)
|
||||
async def pay():
|
||||
result = await LNWallet._pay(w1, pay_req)
|
||||
self.assertEqual(result, True)
|
||||
self.assertTrue(result)
|
||||
gath.cancel()
|
||||
gath = asyncio.gather(pay(), p1._message_loop(), p2._message_loop())
|
||||
async def f():
|
||||
|
||||
Reference in New Issue
Block a user