Test that penalty transactions are RBFed.
(node_factory, bitcoind, executor, chainparams)
| 1530 | |
| 1531 | @pytest.mark.developer("uses dev_sign_last_tx") |
| 1532 | def 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! |
nothing calls this directly
no test coverage detected