MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_permfail_new_commit

Function test_permfail_new_commit

tests/test_closing.py:3163–3200  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

3161
3162
3163def test_permfail_new_commit(node_factory, bitcoind, executor):
3164 # Test case where we have two possible commits: it will use new one.
3165 disconnects = ['-WIRE_REVOKE_AND_ACK', 'permfail']
3166 # Feerates identical so we don't get gratuitous commit to update them
3167 l1 = node_factory.get_node(options={'dev-no-reconnect': None},
3168 feerates=(7500, 7500, 7500, 7500))
3169 l2 = node_factory.get_node(disconnect=disconnects)
3170
3171 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3172 l1.fundchannel(l2, 10**6)
3173
3174 # This will fail at l2's end.
3175 t = executor.submit(l1.pay, l2, 200000000)
3176
3177 l2.daemon.wait_for_log('dev_disconnect permfail')
3178 l2.wait_for_channel_onchain(l1.info['id'])
3179 bitcoind.generate_block(1)
3180 l1.daemon.wait_for_log('Their unilateral tx, new commit point')
3181 l1.daemon.wait_for_log(' to ONCHAIN')
3182 l2.daemon.wait_for_log(' to ONCHAIN')
3183 l2.daemon.wait_for_log(r'Propose ignoring OUR_UNILATERAL/THEIR_HTLC as THEIR_HTLC_TIMEOUT_TO_THEM after block [0-9]* \(5 more blocks\)')
3184
3185 _, txid, blocks = l1.wait_for_onchaind_tx('OUR_HTLC_TIMEOUT_TO_US',
3186 'THEIR_UNILATERAL/OUR_HTLC')
3187 assert blocks == 5
3188
3189 # OK, time out HTLC.
3190 bitcoind.generate_block(5)
3191 bitcoind.generate_block(1, wait_for_mempool=txid)
3192 l1.daemon.wait_for_log('Resolved THEIR_UNILATERAL/OUR_HTLC by our proposal OUR_HTLC_TIMEOUT_TO_US')
3193 l2.daemon.wait_for_log('Ignoring output.*: OUR_UNILATERAL/THEIR_HTLC')
3194
3195 t.cancel()
3196
3197 # Now, 100 blocks it should be done.
3198 bitcoind.generate_block(100)
3199 wait_for(lambda: l1.rpc.listpeers()['peers'] == [])
3200 wait_for(lambda: l2.rpc.listpeers()['peers'] == [])
3201
3202
3203def setup_multihtlc_test(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 9

wait_forFunction · 0.90
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
wait_for_onchaind_txMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected