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

Function test_penalty_rbf_normal

tests/test_closing.py:1532–1652  ·  view source on GitHub ↗

Test that penalty transactions are RBFed.

(node_factory, bitcoind, executor, chainparams)

Source from the content-addressed store, hash-verified

1530
1531@pytest.mark.developer("uses dev_sign_last_tx")
1532def test_penalty_rbf_normal(node_factory, bitcoind, executor, chainparams):
1533 '''
1534 Test that penalty transactions are RBFed.
1535 '''
1536 # We track channel balances, to verify that accounting is ok.
1537 coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
1538 to_self_delay = 10
1539 # l1 is the thief, which causes our honest upstanding lightningd
1540 # code to break, so l1 can fail.
1541 # Initially, disconnect before the HTLC can be resolved.
1542 l1 = node_factory.get_node(options={'dev-disable-commit-after': 1},
1543 may_fail=True, allow_broken_log=True)
1544 l2 = node_factory.get_node(options={'dev-disable-commit-after': 1,
1545 'watchtime-blocks': to_self_delay,
1546 'plugin': coin_mvt_plugin})
1547
1548 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1549 l1.fundchannel(l2, 10**7)
1550 channel_id = first_channel_id(l1, l2)
1551
1552 # Trigger an HTLC being added.
1553 t = executor.submit(l1.pay, l2, 1000000 * 1000)
1554
1555 # Make sure the channel is still alive.
1556 assert len(l1.getactivechannels()) == 2
1557 assert len(l2.getactivechannels()) == 2
1558
1559 # Wait for the disconnection.
1560 l1.daemon.wait_for_log('dev-disable-commit-after: disabling')
1561 l2.daemon.wait_for_log('dev-disable-commit-after: disabling')
1562 # Make sure l1 gets the new HTLC.
1563 l1.daemon.wait_for_log('got commitsig')
1564
1565 # l1 prepares a theft commitment transaction
1566 theft_tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx']
1567
1568 # Now continue processing until fulfilment.
1569 l1.rpc.dev_reenable_commit(l2.info['id'])
1570 l2.rpc.dev_reenable_commit(l1.info['id'])
1571
1572 # Wait for the fulfilment.
1573 l1.daemon.wait_for_log('peer_in WIRE_UPDATE_FULFILL_HTLC')
1574 l1.daemon.wait_for_log('peer_out WIRE_REVOKE_AND_ACK')
1575 l2.daemon.wait_for_log('peer_out WIRE_UPDATE_FULFILL_HTLC')
1576 l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK')
1577
1578 # Now payment should complete.
1579 t.result(timeout=10)
1580
1581 # l1 goes offline and bribes the miners to censor transactions from l2.
1582 l1.rpc.stop()
1583
1584 def censoring_sendrawtx(r):
1585 return {'id': r['id'], 'result': {}}
1586
1587 l2.daemon.rpcproxy.mock_rpc('sendrawtransaction', censoring_sendrawtx)
1588
1589 # l1 now performs the theft attack!

Callers

nothing calls this directly

Calls 15

first_channel_idFunction · 0.90
sync_blockheightFunction · 0.90
account_balanceFunction · 0.90
anchor_expectedFunction · 0.90
check_utxos_channelFunction · 0.90
get_rbf_txFunction · 0.85
joinMethod · 0.80
getactivechannelsMethod · 0.80
wait_for_logMethod · 0.80
dev_sign_last_txMethod · 0.80
dev_reenable_commitMethod · 0.80
mock_rpcMethod · 0.80

Tested by

no test coverage detected