Skip to content

Commit d623932

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

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

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

433433
# Get pre-splice route.
434434
inv = l3.rpc.invoice(10000000, 'test_route_by_old_scid', 'test_route_by_old_scid')
435+
inv2 = l3.rpc.invoice(10000000, 'test_route_by_old_scid2', 'test_route_by_old_scid2')
435436
route = l1.rpc.getroute(l3.info['id'], 10000000, 1)['route']
436437

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

0 commit comments

Comments
 (0)