Skip to content

Commit f265a95

Browse files
committed
pytest: test persistence of old scids, even if we spliced multiple times.
Signed-off-by: Rusty Russell <[email protected]>
1 parent d1f56eb commit f265a95

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/test_splicing.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,11 @@ def test_splice_stuck_htlc(node_factory, bitcoind, executor):
501501

502502
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
503503
def test_route_by_old_scid(node_factory, bitcoind):
504-
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, opts={'experimental-splicing': None})
504+
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, opts={'experimental-splicing': None, 'may_reconnect': True})
505505

506506
# Get pre-splice route.
507507
inv = l3.rpc.invoice(10000000, 'test_route_by_old_scid', 'test_route_by_old_scid')
508+
inv2 = l3.rpc.invoice(10000000, 'test_route_by_old_scid2', 'test_route_by_old_scid2')
508509
route = l1.rpc.getroute(l3.info['id'], 10000000, 1)['route']
509510

510511
# Do a splice
@@ -525,3 +526,28 @@ def test_route_by_old_scid(node_factory, bitcoind):
525526
# Now l1 tries to send using old scid: should work
526527
l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
527528
l1.rpc.waitsendpay(inv['payment_hash'])
529+
530+
# Let's splice again, so the original scid is two behind the times.
531+
l3.fundwallet(200000)
532+
funds_result = l3.rpc.fundpsbt("109000sat", "slow", 166, excess_as_change=True)
533+
chan_id = l3.get_channel_id(l2)
534+
result = l3.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
535+
result = l3.rpc.splice_update(chan_id, result['psbt'])
536+
assert(result['commitments_secured'] is False)
537+
result = l3.rpc.splice_update(chan_id, result['psbt'])
538+
assert(result['commitments_secured'] is True)
539+
result = l3.rpc.signpsbt(result['psbt'])
540+
result = l3.rpc.splice_signed(chan_id, result['signed_psbt'])
541+
542+
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'CHANNELD_AWAITING_SPLICE')
543+
bitcoind.generate_block(6, wait_for_mempool=1)
544+
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL')
545+
546+
# Now restart l2, make sure it remembers the original!
547+
l2.restart()
548+
l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
549+
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
550+
551+
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['connected'] is True)
552+
l1.rpc.sendpay(route, inv2['payment_hash'], payment_secret=inv2['payment_secret'])
553+
l1.rpc.waitsendpay(inv2['payment_hash'])

0 commit comments

Comments
 (0)