@@ -863,3 +863,60 @@ def test_unannounced(node_factory):
863863 b12 = l1 .rpc .fetchinvoice (offer , "21sat" )["invoice" ]
864864 ret = l1 .rpc .call ("renepay" , {"invstring" : b12 })
865865 assert ret ["status" ] == "complete"
866+
867+
868+ def test_renepay_no_mpp (node_factory , chainparams ):
869+ """Renepay should produce single route solutions for invoices that don't
870+ signal their support for MPP."""
871+ def test_bit (features , bit_pos ):
872+ return (features [bit_pos // 8 ] & (1 << (bit_pos % 8 ))) != 0
873+
874+ # l4 does not support MPP
875+ l1 , l2 , l3 , l4 = node_factory .get_nodes (
876+ 4 , opts = [{}, {}, {}, {"dev-force-features" : - 17 }]
877+ )
878+
879+ # make it so such that it would be convenient to use MPP, eg. higher
880+ # probability of success
881+ amount = "900000sat"
882+ start_channels (
883+ [(l1 , l2 , 1000_000 ), (l2 , l4 , 1000_000 ), (l1 , l3 , 1000_000 ), (l3 , l4 , 1000_000 )]
884+ )
885+
886+ # a normal call to getroutes returns two routes
887+ routes = l1 .rpc .getroutes (
888+ source = l1 .info ["id" ],
889+ destination = l4 .info ["id" ],
890+ amount_msat = amount ,
891+ layers = [],
892+ maxfee_msat = "1000sat" ,
893+ final_cltv = 0 ,
894+ )["routes" ]
895+ assert len (routes ) == 2
896+
897+ inv = l4 .rpc .invoice (amount , "test_no_mpp" , "test_no_mpp" )["bolt11" ]
898+
899+ # check that MPP feature is not present
900+ features = bytearray .fromhex (l1 .rpc .decode (inv )["features" ])
901+ features .reverse ()
902+ # var_onion_optin is compulsory
903+ assert test_bit (features , 8 )
904+ # payment_secret is compulsory
905+ assert test_bit (features , 14 )
906+ # basic_mpp should not be present
907+ assert not test_bit (features , 16 )
908+ assert not test_bit (features , 17 )
909+
910+ # pay with renepay
911+ ret = l1 .rpc .call ("renepay" , {"invstring" : inv })
912+ l1 .wait_for_htlcs ()
913+
914+ # check that payment succeed
915+ # FIXME: lightningd on l4 will accept the MPP HTLCs (>1 routes) even if we
916+ # have disabled the feature.
917+ assert ret ["status" ] == "complete"
918+ # check that number of parts was 1
919+ assert ret ["parts" ] == 1
920+ # check that destination received the payment
921+ receipt = only_one (l4 .rpc .listinvoices ("test_no_mpp" )["invoices" ])
922+ assert receipt ["amount_received_msat" ] == Millisatoshi (amount )
0 commit comments