mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
opening: save the correct commitment tx when we are the fundee.
We were saving *our* commitment tx, not theirs. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -447,6 +447,48 @@ class LightningDTests(BaseLightningDTests):
|
||||
bitcoind.rpc.generate(6)
|
||||
l2.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||
|
||||
def test_onchain_first_commit(self):
|
||||
"""Onchain handling where funder immediately drops to chain"""
|
||||
|
||||
# HTLC 1->2, 1 fails just after funding.
|
||||
disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail']
|
||||
l1 = self.node_factory.get_node(disconnect=disconnects)
|
||||
l2 = self.node_factory.get_node()
|
||||
|
||||
l1.rpc.connect('localhost', l2.info['port'], l2.info['id'])
|
||||
|
||||
# Like fundchannel, but we'll probably fail before CHANNELD_NORMAL.
|
||||
addr = l1.rpc.newaddr()['address']
|
||||
|
||||
txid = l1.bitcoin.rpc.sendtoaddress(addr, 10**6 / 10**8 + 0.01)
|
||||
tx = l1.bitcoin.rpc.getrawtransaction(txid)
|
||||
|
||||
l1.rpc.addfunds(tx)
|
||||
l1.rpc.fundchannel(l2.info['id'], 10**6)
|
||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||
|
||||
l1.bitcoin.rpc.generate(1)
|
||||
|
||||
# l1 will drop to chain.
|
||||
l1.daemon.wait_for_log('permfail')
|
||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||
l1.bitcoin.rpc.generate(1)
|
||||
l1.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
|
||||
l2.daemon.wait_for_log('-> ONCHAIND_THEIR_UNILATERAL')
|
||||
|
||||
# 6 later, l1 should collect its to-self payment.
|
||||
bitcoind.rpc.generate(6)
|
||||
l1.daemon.wait_for_log('Broadcasting OUR_DELAYED_RETURN_TO_WALLET .* to resolve OUR_UNILATERAL/DELAYED_OUTPUT_TO_US')
|
||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||
|
||||
# 94 later, l2 is done.
|
||||
bitcoind.rpc.generate(94)
|
||||
l2.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||
|
||||
# Now, 100 blocks and l1 should be done.
|
||||
bitcoind.rpc.generate(6)
|
||||
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||
|
||||
def test_onchain_dust_out(self):
|
||||
"""Onchain handling of outgoing dust htlcs (they should fail)"""
|
||||
# HTLC 1->2, 1 fails after it's irrevocably committed
|
||||
|
||||
Reference in New Issue
Block a user