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

Function test_penalty_htlc_tx_timeout

tests/test_closing.py:1370–1597  ·  view source on GitHub ↗

Test that the penalizing node claims any published HTLC transactions Node topology: l1 <-> l2 <-> l3 <-> l4 ^---> l5 l1 pushes money to l5, who doesn't fulfill (freezing htlc across l2-l3) l4 pushes money to l1, who doesn't fulfill (freezing ht

(node_factory, bitcoind, chainparams, anchors)

Source from the content-addressed store, hash-verified

1368@pytest.mark.slow_test
1369@pytest.mark.parametrize("anchors", [False, True])
1370def test_penalty_htlc_tx_timeout(node_factory, bitcoind, chainparams, anchors):
1371 """ Test that the penalizing node claims any published
1372 HTLC transactions
1373
1374 Node topology:
1375 l1 <-> l2 <-> l3 <-> l4
1376 ^---> l5
1377
1378 l1 pushes money to l5, who doesn&#x27;t fulfill (freezing htlc across l2-l3)
1379 l4 pushes money to l1, who doesn&#x27;t fulfill (freezing htlc across l2-l3)
1380 we snapshot l2
1381 l2 pushes money to l3 (updating state)
1382 l2 + l3 go offline; l2 is backed up from snapshot
1383 l1 fails the channel with l2, fulfilling the stranded htlc onchain
1384 l2 comes back online, force closes channel with l3
1385
1386 block chain advances, l2 broadcasts the timeout htlc_tx + fulfill htlc_tx
1387 both of which have a delay. l2 goes ahead and 'steals back' their
1388 output + the htlc they fulfill
1389
1390 l3 comes back online, sees l2&#x27;s cheat. takes funds from htlc timeout tx
1391 some blocks are mined. the dust settles.
1392
1393 we check the accounting.
1394 """
1395
1396 if chainparams['elements'] and anchors:
1397 pytest.skip('elementsd anchors unsupported')
1398
1399 # We track channel balances, to verify that accounting is ok.
1400 coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
1401 opts = [
1402 {
1403 'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC'],
1404 'may_reconnect': True,
1405 'dev-no-reconnect': None,
1406 }, {
1407 'plugin': coin_mvt_plugin,
1408 'dev-no-reconnect': None,
1409 'may_reconnect': True,
1410 'broken_log': 'onchaind.*Unknown spend'
1411 }, {
1412 'plugin': coin_mvt_plugin,
1413 'dev-no-reconnect': None,
1414 'may_reconnect': True,
1415 # This can happen, if l2 collects htlc before we penalize.
1416 'broken_log': 'HTLC already resolved by THEIR_HTLC_TIMEOUT_TO_THEM when we found preimage'
1417 }, {
1418 'dev-no-reconnect': None,
1419 }, {
1420 'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC'],
1421 'may_reconnect': True,
1422 'dev-no-reconnect': None,
1423 }
1424 ]
1425 if anchors is False:
1426 for opt in opts:
1427 opt['dev-force-features'] = "-23"

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
first_channel_idFunction · 0.90
sync_blockheightFunction · 0.90
account_balanceFunction · 0.90
check_utxos_channelFunction · 0.90
joinMethod · 0.80
get_nodesMethod · 0.80
join_nodesMethod · 0.80
generate_blockMethod · 0.80
single_routeMethod · 0.80
sendpayMethod · 0.80
wait_for_logMethod · 0.80

Tested by

no test coverage detected