Skip to content

Commit dde28a5

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

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
@@ -424,10 +424,11 @@ def test_splice_stuck_htlc(node_factory, bitcoind, executor):
424424

425425

426426
def test_route_by_old_scid(node_factory, bitcoind):
427-
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, opts={'experimental-splicing': None})
427+
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, opts={'experimental-splicing': None, 'may_reconnect': True})
428428

429429
# Get pre-splice route.
430430
inv = l3.rpc.invoice(10000000, 'test_route_by_old_scid', 'test_route_by_old_scid')
431+
inv2 = l3.rpc.invoice(10000000, 'test_route_by_old_scid2', 'test_route_by_old_scid2')
431432
route = l1.rpc.getroute(l3.info['id'], 10000000, 1)['route']
432433

433434
# Do a splice
@@ -448,3 +449,28 @@ def test_route_by_old_scid(node_factory, bitcoind):
448449
# Now l1 tries to send using old scid: should work
449450
l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
450451
l1.rpc.waitsendpay(inv['payment_hash'])
452+
453+
# Let's splice again, so the original scid is two behind the times.
454+
l3.fundwallet(200000)
455+
funds_result = l3.rpc.fundpsbt("109000sat", "slow", 166, excess_as_change=True)
456+
chan_id = l3.get_channel_id(l2)
457+
result = l3.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
458+
result = l3.rpc.splice_update(chan_id, result['psbt'])
459+
assert(result['commitments_secured'] is False)
460+
result = l3.rpc.splice_update(chan_id, result['psbt'])
461+
assert(result['commitments_secured'] is True)
462+
result = l3.rpc.signpsbt(result['psbt'])
463+
result = l3.rpc.splice_signed(chan_id, result['signed_psbt'])
464+
465+
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'CHANNELD_AWAITING_SPLICE')
466+
bitcoind.generate_block(6, wait_for_mempool=1)
467+
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL')
468+
469+
# Now restart l2, make sure it remembers the original!
470+
l2.restart()
471+
l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
472+
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
473+
474+
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['connected'] is True)
475+
l1.rpc.sendpay(route, inv2['payment_hash'], payment_secret=inv2['payment_secret'])
476+
l1.rpc.waitsendpay(inv2['payment_hash'])

0 commit comments

Comments
 (0)