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

Function test_scid_alias_private

tests/test_opening.py:2624–2686  ·  view source on GitHub ↗

Test that we don't allow use of real scid for scid_alias-type channels

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2622
2623
2624def test_scid_alias_private(node_factory, bitcoind):
2625 """Test that we don't allow use of real scid for scid_alias-type channels"""
2626 l1, l2, l3 = node_factory.line_graph(3, fundchannel=False, opts=[{}, {},
2627 {'log-level': 'io'}])
2628
2629 l2.fundwallet(5000000)
2630 fc = l2.rpc.fundchannel(l3.info['id'], 'all', announce=False)
2631 assert 'scid_alias/even' in fc['channel_type']['names']
2632
2633 bitcoind.generate_block(1, wait_for_mempool=1)
2634 wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL')
2635
2636 chan = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])
2637 assert chan['private'] is True
2638 scid23 = chan['short_channel_id']
2639 alias23 = chan['alias']['local']
2640
2641 # Create l1<->l2 channel, make sure l3 sees it so it will routehint via
2642 # l2 (otherwise it sees it as a deadend!)
2643 l1.fundwallet(5000000)
2644 l1.rpc.fundchannel(l2.info['id'], 'all')
2645 bitcoind.generate_block(6, wait_for_mempool=1)
2646 wait_for(lambda: len(l3.rpc.listchannels(source=l1.info['id'])['channels']) == 1)
2647
2648 chan = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
2649 assert chan['private'] is False
2650 scid12 = chan['short_channel_id']
2651
2652 # Make sure it sees both sides of private channel in gossmap!
2653 wait_for(lambda: 'remote' in only_one(l3.rpc.listpeerchannels(l2.info['id'])['channels'])['updates'])
2654
2655 # BOLT #2:
2656 # - if `channel_type` has `option_scid_alias` set:
2657 # - MUST NOT use the real `short_channel_id` in BOLT 11 `r` fields.
2658 inv = l3.rpc.invoice(10, 'test_scid_alias_private', 'desc')
2659 assert only_one(only_one(l1.rpc.decode(inv['bolt11'])['routes']))['short_channel_id'] == alias23
2660
2661 # BOLT #2:
2662 # - if `channel_type` has `option_scid_alias` set:
2663 # - MUST NOT allow incoming HTLCs to this channel using the real `short_channel_id`
2664 route = [{'amount_msat': 11,
2665 'id': l2.info['id'],
2666 'delay': 12,
2667 'channel': scid12},
2668 {'amount_msat': 10,
2669 'id': l3.info['id'],
2670 'delay': 6,
2671 'channel': scid23}]
2672 l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])
2673 with pytest.raises(RpcError) as err:
2674 l1.rpc.waitsendpay(inv['payment_hash'])
2675
2676 # PERM|10
2677 WIRE_UNKNOWN_NEXT_PEER = 0x4000 | 10
2678 assert err.value.error['data']['failcode'] == WIRE_UNKNOWN_NEXT_PEER
2679 assert err.value.error['data']['erring_node'] == l2.info['id']
2680 assert err.value.error['data']['erring_channel'] == scid23
2681

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
sendpayMethod · 0.80
waitsendpayMethod · 0.80
fundchannelMethod · 0.45
listchannelsMethod · 0.45
invoiceMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected