electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit ece75c3244a552af83d7bdfb0062396579169e38
parent 28dc1928a0cd3a2bfa8fa1f15fc5a6fcdf5112b3
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 11 Feb 2020 19:53:21 +0100

test_lnpeer: simple test of channel_reestablish

Diffstat:
Melectrum/tests/test_lnpeer.py | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/electrum/tests/test_lnpeer.py b/electrum/tests/test_lnpeer.py @@ -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 +from electrum.lnchannel import channel_states, peer_states from electrum.lnrouter import LNPathFinder from electrum.channel_db import ChannelDB from electrum.lnworker import LNWallet, NoPathFound @@ -218,6 +218,21 @@ class TestPeer(ElectrumTestCase): ]) return lnencode(lnaddr, w2.node_keypair.privkey) + def test_reestablish(self): + p1, p2, w1, w2, _q1, _q2 = self.prepare_peers() + async def reestablish(): + await asyncio.gather( + p1.reestablish_channel(self.alice_channel), + p2.reestablish_channel(self.bob_channel)) + self.assertEqual(self.alice_channel.peer_state, peer_states.GOOD) + self.assertEqual(self.bob_channel.peer_state, peer_states.GOOD) + gath.cancel() + gath = asyncio.gather(reestablish(), p1._message_loop(), p2._message_loop()) + async def f(): + await gath + with self.assertRaises(concurrent.futures.CancelledError): + run(f()) + def test_payment(self): p1, p2, w1, w2, _q1, _q2 = self.prepare_peers() pay_req = self.prepare_invoice(w2)