lnpeer: closing fee negociation:
- use fee_rate from config - set upper bound on fee - add test_close to test_lnpeer
This commit is contained in:
@@ -165,6 +165,9 @@ def create_test_channels(feerate=6000, local=None, remote=None):
|
||||
alice.hm.channel_open_finished()
|
||||
bob.hm.channel_open_finished()
|
||||
|
||||
# TODO: sweep_address in lnchannel.py should use static_remotekey
|
||||
alice.sweep_address = bitcoin.pubkey_to_address('p2wpkh', alice.config[LOCAL].payment_basepoint.pubkey.hex())
|
||||
bob.sweep_address = bitcoin.pubkey_to_address('p2wpkh', bob.config[LOCAL].payment_basepoint.pubkey.hex())
|
||||
return alice, bob
|
||||
|
||||
class TestFee(ElectrumTestCase):
|
||||
|
||||
@@ -283,6 +283,24 @@ class TestPeer(ElectrumTestCase):
|
||||
with self.assertRaises(concurrent.futures.CancelledError):
|
||||
run(f())
|
||||
|
||||
def test_close(self):
|
||||
alice_channel, bob_channel = create_test_channels()
|
||||
p1, p2, w1, w2, _q1, _q2 = self.prepare_peers(alice_channel, bob_channel)
|
||||
w1.network.config.set_key('dynamic_fees', False)
|
||||
w2.network.config.set_key('dynamic_fees', False)
|
||||
w1.network.config.set_key('fee_per_kb', 5000)
|
||||
w2.network.config.set_key('fee_per_kb', 1000)
|
||||
async def pay():
|
||||
await asyncio.wait_for(p1.initialized, 1)
|
||||
await asyncio.wait_for(p2.initialized, 1)
|
||||
await p1.close_channel(alice_channel.channel_id)
|
||||
gath.cancel()
|
||||
gath = asyncio.gather(pay(), p1._message_loop(), p2._message_loop())
|
||||
async def f():
|
||||
await gath
|
||||
with self.assertRaises(concurrent.futures.CancelledError):
|
||||
run(f())
|
||||
|
||||
def test_channel_usage_after_closing(self):
|
||||
alice_channel, bob_channel = create_test_channels()
|
||||
p1, p2, w1, w2, q1, q2 = self.prepare_peers(alice_channel, bob_channel)
|
||||
|
||||
Reference in New Issue
Block a user