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

Function test_splice_aggravated_close

tests/test_splice.py:928–963  ·  view source on GitHub ↗
(node_factory, bitcoind, chainparams, restart_node)

Source from the content-addressed store, hash-verified

926@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
927@pytest.mark.parametrize("restart_node", [False, True])
928def test_splice_aggravated_close(node_factory, bitcoind, chainparams, restart_node):
929 # Using the $ before message simply *drops* the packet (no disconnect occurs).
930 disconnects = ['$WIRE_SPLICE_LOCKED']
931 l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True,
932 opts=[{}, {'disconnect': disconnects}]) # L2 will never send the SPLICE_LOCKED
933
934 # Any splice will do
935 l1.rpc.spliceout("*:?", "100000")
936
937 bitcoind.generate_block(6, wait_for_mempool=1)
938 # l2 completes splice locked, but l1 should not
939 l2.daemon.wait_for_log(r'lightningd, splice_locked clearing inflights')
940
941 # Confirm l1 never completed the splice but l2 did.
942 p1 = only_one(l1.rpc.listpeerchannels(peer_id=l2.info['id'])['channels'])
943 p2 = only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])
944 assert 'inflight' in p1
945 assert 'inflight' not in p2
946
947 # Now have l2 disconnect and unilateral close on the post-splice channel
948 l2.rpc.disconnect(l1.info['id'], True)
949 l2.rpc.close(l1.info['id'], 1)
950
951 if restart_node:
952 l1.restart()
953
954 # Mine the post-splice channel close
955 bitcoind.generate_block(6, wait_for_mempool=1)
956
957 # l2 will process it easily
958 l2.daemon.wait_for_log(r'State changed from AWAITING_UNILATERAL to FUNDING_SPEND_SEEN')
959 # l1 has to work harder to process it, so we check it last
960 l1.daemon.wait_for_log(r'State changed from AWAITING_UNILATERAL to FUNDING_SPEND_SEEN')
961
962 state_change_re = re.compile(r'State changed from \S+ to FUNDING_SPEND_SEEN')
963 assert len([l for l in l2.daemon.logs if state_change_re.search(l)]) == 1

Callers

nothing calls this directly

Calls 10

only_oneFunction · 0.90
line_graphMethod · 0.80
spliceoutMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
listpeerchannelsMethod · 0.80
restartMethod · 0.80
compileMethod · 0.80
disconnectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected