diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 10f71ae8d..b021e05cf 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1648,6 +1648,8 @@ class LNWallet(LNWorker): is_mpp = sum(len(x) for x in list(sc.config.values())) > 1 if is_mpp and not invoice_features.supports(LnFeatures.BASIC_MPP_OPT): continue + if not is_mpp and self.config.TEST_FORCE_MPP: + continue self.logger.info(f"trying split configuration: {sc.config.values()} rating: {sc.rating}") routes = [] try: diff --git a/electrum/simple_config.py b/electrum/simple_config.py index 43f835a5e..b0feab9e5 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -893,6 +893,7 @@ class SimpleConfig(Logger): EXPERIMENTAL_LN_FORWARD_TRAMPOLINE_PAYMENTS = ConfigVar('lightning_forward_trampoline_payments', default=False, type_=bool) TEST_FAIL_HTLCS_WITH_TEMP_NODE_FAILURE = ConfigVar('test_fail_htlcs_with_temp_node_failure', default=False, type_=bool) TEST_FAIL_HTLCS_AS_MALFORMED = ConfigVar('test_fail_malformed_htlc', default=False, type_=bool) + TEST_FORCE_MPP = ConfigVar('test_force_mpp', default=False, type_=bool) TEST_SHUTDOWN_FEE = ConfigVar('test_shutdown_fee', default=None, type_=int) TEST_SHUTDOWN_FEE_RANGE = ConfigVar('test_shutdown_fee_range', default=None) TEST_SHUTDOWN_LEGACY = ConfigVar('test_shutdown_legacy', default=False, type_=bool) diff --git a/electrum/tests/test_lnpeer.py b/electrum/tests/test_lnpeer.py index caf5d9b45..490be6f9c 100644 --- a/electrum/tests/test_lnpeer.py +++ b/electrum/tests/test_lnpeer.py @@ -1180,7 +1180,7 @@ class TestPeer(ElectrumTestCase): graph = self.prepare_chans_and_peers_in_graph(self.GRAPH_DEFINITIONS['square_graph']) await self._run_mpp(graph, {'mpp_invoice': False}, {'mpp_invoice': True}) - async def _run_trampoline_payment(self, is_legacy, direct, drop_dave=None): + async def _run_trampoline_payment(self, is_legacy, direct, drop_dave=None, test_mpp_consolidation=False): if drop_dave is None: drop_dave = [] async def pay(lnaddr, pay_req): @@ -1217,7 +1217,16 @@ class TestPeer(ElectrumTestCase): # insert a channel from bob to carol graph_definition['bob']['channels']['carol'] = high_fee_channel + if test_mpp_consolidation: + # deplete alice to carol so that all htlcs go through bob + graph_definition['alice']['channels']['carol'] = depleted_channel + graph = self.prepare_chans_and_peers_in_graph(graph_definition) + + if test_mpp_consolidation: + graph.workers['dave'].features |= LnFeatures.BASIC_MPP_OPT + graph.workers['alice'].network.config.TEST_FORCE_MPP = True + peers = graph.peers.values() if is_legacy: # turn off trampoline features in invoice @@ -1231,6 +1240,11 @@ class TestPeer(ElectrumTestCase): await f() + @needs_test_with_all_chacha20_implementations + async def test_trampoline_mpp_consolidation(self): + with self.assertRaises(PaymentDone): + await self._run_trampoline_payment(is_legacy=True, direct=False, test_mpp_consolidation=True) + @needs_test_with_all_chacha20_implementations async def test_payment_trampoline_legacy(self): with self.assertRaises(PaymentDone):