(node_factory, bitcoind)
| 208 | @pytest.mark.openchannel('v2') |
| 209 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 210 | def test_splice_gossip(node_factory, bitcoind): |
| 211 | l1, l2, l3 = node_factory.line_graph(3, fundamount=1000000, wait_for_announce=True) |
| 212 | |
| 213 | chan_id = l1.get_channel_id(l2) |
| 214 | pre_splice_scid = first_scid(l1, l2) |
| 215 | |
| 216 | # add extra sats to pay fee |
| 217 | funds_result = l1.rpc.fundpsbt("111722sat", 0, 0, excess_as_change=True) |
| 218 | |
| 219 | result = l1.rpc.splice_init(chan_id, 100000, funds_result['psbt']) |
| 220 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 221 | assert(result['commitments_secured'] is False) |
| 222 | result = l1.rpc.splice_update(chan_id, result['psbt']) |
| 223 | assert(result['commitments_secured'] is True) |
| 224 | result = l1.rpc.signpsbt(result['psbt']) |
| 225 | result = l1.rpc.splice_signed(chan_id, result['signed_psbt']) |
| 226 | |
| 227 | wait_for(lambda: only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'CHANNELD_AWAITING_SPLICE') |
| 228 | wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['state'] == 'CHANNELD_AWAITING_SPLICE') |
| 229 | |
| 230 | bitcoind.generate_block(5, wait_for_mempool=result['txid']) |
| 231 | |
| 232 | # l3 will see channel dying, but still consider it OK for 72 blocks. |
| 233 | l3.daemon.wait_for_log(f'gossipd: channel {pre_splice_scid} closing soon due to the funding outpoint being spent') |
| 234 | assert len(l3.rpc.listchannels(short_channel_id=pre_splice_scid)['channels']) == 2 |
| 235 | assert len(l3.rpc.listchannels(source=l1.info['id'])['channels']) == 1 |
| 236 | |
| 237 | # Final one will allow splice announcement to proceed. |
| 238 | bitcoind.generate_block(1) |
| 239 | wait_for(lambda: only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL') |
| 240 | wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL') |
| 241 | |
| 242 | post_splice_scid = first_scid(l1, l2) |
| 243 | assert post_splice_scid != pre_splice_scid |
| 244 | |
| 245 | # l3 should see the new channel now. |
| 246 | wait_for(lambda: len(l3.rpc.listchannels(short_channel_id=post_splice_scid)['channels']) == 2) |
| 247 | assert len(l3.rpc.listchannels(short_channel_id=pre_splice_scid)['channels']) == 2 |
| 248 | |
| 249 | bitcoind.generate_block(67) |
| 250 | |
| 251 | # The old channel should fall off l3's perspective |
| 252 | wait_for(lambda: l3.rpc.listchannels(short_channel_id=pre_splice_scid)['channels'] == []) |
| 253 | assert len(l3.rpc.listchannels(short_channel_id=post_splice_scid)['channels']) == 2 |
| 254 | |
| 255 | # Check that the splice doesn't generate a unilateral close transaction |
| 256 | time.sleep(5) |
| 257 | assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0 |
| 258 | |
| 259 | # Still looks normal from both sides |
| 260 | assert only_one(l1.rpc.listpeerchannels()['channels'])['short_channel_id'] == post_splice_scid |
| 261 | assert only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL' |
| 262 | assert only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['short_channel_id'] == post_splice_scid |
| 263 | assert only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL' |
| 264 | |
| 265 | # Check for channel announcement failure |
| 266 | assert not l1.daemon.is_in_log("invalid local_channel_announcement") |
| 267 | assert not l2.daemon.is_in_log("invalid local_channel_announcement") |
nothing calls this directly
no test coverage detected