@@ -308,6 +308,46 @@ def test_script_two_chan_splice_inout(node_factory, bitcoind):
308308 l2 .rpc .pay (inv ['bolt11' ])
309309
310310
311+ @pytest .mark .xfail (strict = True )
312+ @pytest .mark .openchannel ('v1' )
313+ @pytest .mark .openchannel ('v2' )
314+ @unittest .skipIf (TEST_NETWORK != 'regtest' , 'elementsd doesnt yet support PSBT features we need' )
315+ def test_easy_splice_in (node_factory , bitcoind , chainparams ):
316+ fundamt = 1000000
317+
318+ coin_mvt_plugin = Path (__file__ ).parent / "plugins" / "coin_movements.py"
319+ l1 , l2 = node_factory .line_graph (2 , fundamount = fundamt , wait_for_announce = True ,
320+ opts = {'experimental-splicing' : None ,
321+ 'plugin' : coin_mvt_plugin })
322+
323+ # Splice in 100k sats into first channel
324+ spliceamt = 100000
325+
326+ l1 .rpc .splicein ("*:?" , f"{ spliceamt } " )
327+ p1 = only_one (l1 .rpc .listpeerchannels (peer_id = l2 .info ['id' ])['channels' ])
328+ p2 = only_one (l2 .rpc .listpeerchannels (l1 .info ['id' ])['channels' ])
329+ assert p1 ['inflight' ][0 ]['splice_amount' ] == spliceamt
330+ assert p1 ['inflight' ][0 ]['total_funding_msat' ] == (fundamt + spliceamt ) * 1000
331+ assert p1 ['inflight' ][0 ]['our_funding_msat' ] == fundamt * 1000
332+ assert p2 ['inflight' ][0 ]['splice_amount' ] == 0
333+ assert p2 ['inflight' ][0 ]['total_funding_msat' ] == (fundamt + spliceamt ) * 1000
334+ assert p2 ['inflight' ][0 ]['our_funding_msat' ] == 0
335+ bitcoind .generate_block (6 , wait_for_mempool = 1 )
336+ l2 .daemon .wait_for_log (r'lightningd, splice_locked clearing inflights' )
337+
338+ p1 = only_one (l1 .rpc .listpeerchannels (peer_id = l2 .info ['id' ])['channels' ])
339+ p2 = only_one (l2 .rpc .listpeerchannels (l1 .info ['id' ])['channels' ])
340+ assert p1 ['to_us_msat' ] == (fundamt + spliceamt ) * 1000
341+ assert p1 ['total_msat' ] == (fundamt + spliceamt ) * 1000
342+ assert p2 ['to_us_msat' ] == 0
343+ assert p2 ['total_msat' ] == (fundamt + spliceamt ) * 1000
344+ assert 'inflight' not in p1
345+ assert 'inflight' not in p2
346+
347+ wait_for (lambda : len (l1 .rpc .listfunds ()['outputs' ]) == 1 )
348+ wait_for (lambda : len (l1 .rpc .listfunds ()['channels' ]) == 1 )
349+
350+
311351# Makes channels going from node 1 -> 2, 2 -> 3, etc up to 'qty' number channels.
312352# If balanced is True, than each channel will be balanced -- otherwise the lower
313353# index channel will have funds in the channel to the higher indexed one.
0 commit comments