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

Function test_partial_payment

tests/test_pay.py:3080–3251  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

3078@pytest.mark.openchannel('v1')
3079@pytest.mark.openchannel('v2')
3080def test_partial_payment(node_factory, bitcoind, executor):
3081 # We want to test two payments at the same time, before we send commit
3082 l1, l2, l3, l4 = node_factory.get_nodes(4, [{}] + [{'dev-disable-commit-after': 0, 'dev-no-htlc-timeout': None}] * 2 + [{'plugin': os.path.join(os.getcwd(), 'tests/plugins/print_htlc_onion.py')}])
3083
3084 # Two routes to l4: one via l2, and one via l3.
3085 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3086 l1.fundchannel(l2, 100000)
3087 l1.rpc.connect(l3.info['id'], 'localhost', l3.port)
3088 l1.fundchannel(l3, 100000)
3089 l2.rpc.connect(l4.info['id'], 'localhost', l4.port)
3090 scid24, _ = l2.fundchannel(l4, 100000)
3091 l3.rpc.connect(l4.info['id'], 'localhost', l4.port)
3092 scid34, _ = l3.fundchannel(l4, 100000)
3093 mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
3094
3095 # Wait until l1 knows about all channels.
3096 wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8)
3097
3098 inv = l4.rpc.invoice(1000, 'inv', 'inv')
3099 paysecret = l4.rpc.decode(inv['bolt11'])['payment_secret']
3100
3101 # Separate routes for each part of the payment.
3102 l1.rpc.askrene_create_layer(layer='excl_l2l4')
3103 l1.rpc.askrene_update_channel(layer='excl_l2l4', short_channel_id_dir=scid24 + '/0', enabled=False)
3104 l1.rpc.askrene_update_channel(layer='excl_l2l4', short_channel_id_dir=scid24 + '/1', enabled=False)
3105 r134 = only_one(l1.rpc.getroutes(l1.info['id'], l4.info['id'], 501, layers=['excl_l2l4', 'auto.localchans', 'auto.sourcefree'], maxfee_msat=10000000, final_cltv=9, maxparts=1)['routes'])['path']
3106 l1.rpc.askrene_remove_layer(layer='excl_l2l4')
3107
3108 l1.rpc.askrene_create_layer(layer='excl_l3l4')
3109 l1.rpc.askrene_update_channel(layer='excl_l3l4', short_channel_id_dir=scid34 + '/0', enabled=False)
3110 l1.rpc.askrene_update_channel(layer='excl_l3l4', short_channel_id_dir=scid34 + '/1', enabled=False)
3111 r124 = only_one(l1.rpc.getroutes(l1.info['id'], l4.info['id'], 499, layers=['excl_l3l4', 'auto.localchans', 'auto.sourcefree'], maxfee_msat=10000000, final_cltv=9, maxparts=1)['routes'])['path']
3112 l1.rpc.askrene_remove_layer(layer='excl_l3l4')
3113
3114 # These can happen in parallel.
3115 l1.rpc.sendpay(
3116 route=r134,
3117 payment_hash=inv['payment_hash'],
3118 amount_msat=1000,
3119 bolt11=inv['bolt11'],
3120 payment_secret=paysecret,
3121 partid=1,
3122 groupid=1
3123 )
3124
3125 # Can't mix non-parallel payment!
3126 with pytest.raises(RpcError, match=r'Already have parallel payment in progress'):
3127 l1.rpc.sendpay(
3128 route=r124,
3129 payment_hash=inv['payment_hash'],
3130 amount_msat=499,
3131 payment_secret=paysecret,
3132 groupid=1,
3133 )
3134
3135 # It will not allow a parallel with different msatoshi!
3136 with pytest.raises(RpcError, match=r'msatoshi was previously 1000msat, now 999msat'):
3137 l1.rpc.sendpay(

Callers

nothing calls this directly

Calls 15

mine_funding_to_announceFunction · 0.90
wait_forFunction · 0.90
only_oneFunction · 0.90
MillisatoshiClass · 0.90
get_nodesMethod · 0.80
joinMethod · 0.80
getroutesMethod · 0.80
sendpayMethod · 0.80
wait_for_logsMethod · 0.80
wait_for_logMethod · 0.80
dev_reenable_commitMethod · 0.80
waitsendpayMethod · 0.80

Tested by

no test coverage detected