|
12 | 12 | @pytest.mark.openchannel('v1') |
13 | 13 | @pytest.mark.openchannel('v2') |
14 | 14 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
15 | | -@flaky |
16 | 15 | def test_splice(node_factory, bitcoind): |
17 | 16 | l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True, opts={'experimental-splicing': None}) |
18 | 17 |
|
@@ -49,6 +48,63 @@ def test_splice(node_factory, bitcoind): |
49 | 48 | assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0 |
50 | 49 |
|
51 | 50 |
|
| 51 | +@pytest.mark.openchannel('v1') |
| 52 | +@pytest.mark.openchannel('v2') |
| 53 | +@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 54 | +def test_splice_rbf(node_factory, bitcoind): |
| 55 | + l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True, opts={'experimental-splicing': None}) |
| 56 | + |
| 57 | + chan_id = l1.get_channel_id(l2) |
| 58 | + |
| 59 | + funds_result = l1.rpc.addpsbtoutput(100000) |
| 60 | + |
| 61 | + # Pay with fee by subjtracting 5000 from channel balance |
| 62 | + result = l1.rpc.splice_init(chan_id, -105000, funds_result['psbt']) |
| 63 | + result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 64 | + assert(result['commitments_secured'] is False) |
| 65 | + result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 66 | + assert(result['commitments_secured'] is True) |
| 67 | + result = l1.rpc.splice_signed(chan_id, result['psbt']) |
| 68 | + |
| 69 | + l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 70 | + l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 71 | + |
| 72 | + mempool = bitcoind.rpc.getrawmempool(True) |
| 73 | + assert len(list(mempool.keys())) == 1 |
| 74 | + assert result['txid'] in list(mempool.keys()) |
| 75 | + |
| 76 | + inv = l2.rpc.invoice(10**2, '1', 'no_1') |
| 77 | + l1.rpc.pay(inv['bolt11']) |
| 78 | + |
| 79 | + funds_result = l1.rpc.addpsbtoutput(100000) |
| 80 | + |
| 81 | + # Pay with fee by subjtracting 5000 from channel balance |
| 82 | + result = l1.rpc.splice_init(chan_id, -110000, funds_result['psbt']) |
| 83 | + result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 84 | + assert(result['commitments_secured'] is False) |
| 85 | + result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 86 | + assert(result['commitments_secured'] is True) |
| 87 | + result = l1.rpc.splice_signed(chan_id, result['psbt']) |
| 88 | + |
| 89 | + l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_AWAITING_SPLICE') |
| 90 | + l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_AWAITING_SPLICE') |
| 91 | + |
| 92 | + inv = l2.rpc.invoice(10**2, '2', 'no_2') |
| 93 | + l1.rpc.pay(inv['bolt11']) |
| 94 | + |
| 95 | + bitcoind.generate_block(6, wait_for_mempool=1) |
| 96 | + |
| 97 | + l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL') |
| 98 | + l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL') |
| 99 | + |
| 100 | + inv = l2.rpc.invoice(10**2, '3', 'no_3') |
| 101 | + l1.rpc.pay(inv['bolt11']) |
| 102 | + |
| 103 | + # Check that the splice doesn't generate a unilateral close transaction |
| 104 | + time.sleep(5) |
| 105 | + assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0 |
| 106 | + |
| 107 | + |
52 | 108 | @pytest.mark.openchannel('v1') |
53 | 109 | @pytest.mark.openchannel('v2') |
54 | 110 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
|
0 commit comments