|
|
@ -10,7 +10,7 @@ from concurrent import futures |
|
|
|
import unittest |
|
|
|
from typing import Iterable, NamedTuple, Tuple, List, Dict |
|
|
|
|
|
|
|
from aiorpcx import TaskGroup, timeout_after, TaskTimeout |
|
|
|
from aiorpcx import timeout_after, TaskTimeout |
|
|
|
|
|
|
|
import electrum |
|
|
|
import electrum.trampoline |
|
|
@ -21,7 +21,7 @@ from electrum.ecc import ECPrivkey |
|
|
|
from electrum import simple_config, lnutil |
|
|
|
from electrum.lnaddr import lnencode, LnAddr, lndecode |
|
|
|
from electrum.bitcoin import COIN, sha256 |
|
|
|
from electrum.util import bh2u, create_and_start_event_loop, NetworkRetryManager, bfh |
|
|
|
from electrum.util import bh2u, create_and_start_event_loop, NetworkRetryManager, bfh, OldTaskGroup |
|
|
|
from electrum.lnpeer import Peer, UpfrontShutdownScriptViolation |
|
|
|
from electrum.lnutil import LNPeerAddr, Keypair, privkey_to_pubkey |
|
|
|
from electrum.lnutil import LightningPeerConnectionClosed, RemoteMisbehaving |
|
|
@ -125,7 +125,7 @@ class MockLNWallet(Logger, NetworkRetryManager[LNPeerAddr]): |
|
|
|
NetworkRetryManager.__init__(self, max_retry_delay_normal=1, init_retry_delay_normal=1) |
|
|
|
self.node_keypair = local_keypair |
|
|
|
self.network = MockNetwork(tx_queue) |
|
|
|
self.taskgroup = TaskGroup() |
|
|
|
self.taskgroup = OldTaskGroup() |
|
|
|
self.lnwatcher = None |
|
|
|
self.listen_server = None |
|
|
|
self._channels = {chan.channel_id: chan for chan in chans} |
|
|
@ -365,7 +365,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
|
|
|
|
def tearDown(self): |
|
|
|
async def cleanup_lnworkers(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for lnworker in self._lnworkers_created: |
|
|
|
await group.spawn(lnworker.stop()) |
|
|
|
self._lnworkers_created.clear() |
|
|
@ -569,7 +569,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
self.assertEqual(PR_PAID, w2.get_payment_status(lnaddr.paymenthash)) |
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
await group.spawn(p1._message_loop()) |
|
|
|
await group.spawn(p1.htlc_switch()) |
|
|
|
await group.spawn(p2._message_loop()) |
|
|
@ -643,7 +643,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
raise PaymentDone() |
|
|
|
|
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
await group.spawn(p1._message_loop()) |
|
|
|
await group.spawn(p1.htlc_switch()) |
|
|
|
await group.spawn(p2._message_loop()) |
|
|
@ -667,10 +667,10 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
async with max_htlcs_in_flight: |
|
|
|
await w1.pay_invoice(pay_req) |
|
|
|
async def many_payments(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
pay_reqs_tasks = [await group.spawn(self.prepare_invoice(w2, amount_msat=payment_value_msat)) |
|
|
|
for i in range(num_payments)] |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for pay_req_task in pay_reqs_tasks: |
|
|
|
lnaddr, pay_req = pay_req_task.result() |
|
|
|
await group.spawn(single_payment(pay_req)) |
|
|
@ -696,7 +696,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
self.assertEqual(PR_PAID, graph.workers['dave'].get_payment_status(lnaddr.paymenthash)) |
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -740,7 +740,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
[edge.short_channel_id for edge in log[0].route]) |
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -764,7 +764,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
self.assertEqual(OnionFailureCode.TEMPORARY_NODE_FAILURE, log[0].failure_msg.code) |
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -799,7 +799,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
self.assertEqual(500100000000, graph.channels[('dave', 'bob')].balance(LOCAL)) |
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -862,7 +862,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
|
|
|
|
raise PaymentDone() |
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -909,7 +909,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
raise NoPathFound() |
|
|
|
|
|
|
|
async def f(kwargs): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -948,7 +948,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
|
|
|
|
async def f(): |
|
|
|
await turn_on_trampoline_alice() |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -1026,7 +1026,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
raise SuccessfulTest() |
|
|
|
|
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in peers: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -1196,7 +1196,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
raise SuccessfulTest() |
|
|
|
|
|
|
|
async def f(): |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
for peer in [p1, p2]: |
|
|
|
await group.spawn(peer._message_loop()) |
|
|
|
await group.spawn(peer.htlc_switch()) |
|
|
@ -1223,7 +1223,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
failing_task = None |
|
|
|
async def f(): |
|
|
|
nonlocal failing_task |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
await group.spawn(p1._message_loop()) |
|
|
|
await group.spawn(p1.htlc_switch()) |
|
|
|
failing_task = await group.spawn(p2._message_loop()) |
|
|
@ -1252,7 +1252,7 @@ class TestPeer(TestCaseForTestnet): |
|
|
|
failing_task = None |
|
|
|
async def f(): |
|
|
|
nonlocal failing_task |
|
|
|
async with TaskGroup() as group: |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
await group.spawn(p1._message_loop()) |
|
|
|
await group.spawn(p1.htlc_switch()) |
|
|
|
failing_task = await group.spawn(p2._message_loop()) |
|
|
|