From f9de6a53544286275727723a13e6143ef3cf6d65 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 14 May 2020 19:14:42 +0200 Subject: [PATCH] tests: lnpeer: make debug htlc failure hooks more uniform --- electrum/lnpeer.py | 2 +- electrum/lnworker.py | 1 - electrum/tests/test_lnpeer.py | 5 ++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index 02aa349df..b21f6ac72 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -1509,7 +1509,7 @@ class Peer(Logger): self.logger.info(f"error processing onion packet: {e!r}") error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'') else: - if self.lnworker._fail_htlcs_with_temp_node_failure: + if self.network.config.get('test_fail_htlcs_with_temp_node_failure'): error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'') elif processed_onion.are_we_final: preimage, error_reason = self.maybe_fulfill_htlc( diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 7f6204719..78ef69232 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -494,7 +494,6 @@ class LNWallet(LNWorker): # used in tests self.enable_htlc_settle = asyncio.Event() self.enable_htlc_settle.set() - self._fail_htlcs_with_temp_node_failure = False # note: accessing channels (besides simple lookup) needs self.lock! self._channels = {} # type: Dict[bytes, Channel] diff --git a/electrum/tests/test_lnpeer.py b/electrum/tests/test_lnpeer.py index e8aa304cc..7e673e816 100644 --- a/electrum/tests/test_lnpeer.py +++ b/electrum/tests/test_lnpeer.py @@ -118,7 +118,6 @@ class MockLNWallet(Logger, NetworkRetryManager[LNPeerAddr]): # used in tests self.enable_htlc_settle = asyncio.Event() self.enable_htlc_settle.set() - self._fail_htlcs_with_temp_node_failure = False def get_invoice_status(self, key): pass @@ -543,8 +542,8 @@ class TestPeer(ElectrumTestCase): @needs_test_with_all_chacha20_implementations def test_payment_multihop_temp_node_failure(self): graph = self.prepare_chans_and_peers_in_square() - graph.w_b._fail_htlcs_with_temp_node_failure = True - graph.w_c._fail_htlcs_with_temp_node_failure = True + graph.w_b.network.config.set_key('test_fail_htlcs_with_temp_node_failure', True) + graph.w_c.network.config.set_key('test_fail_htlcs_with_temp_node_failure', True) peers = graph.all_peers() async def pay(pay_req): result, log = await graph.w_a._pay(pay_req)