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

Function test_getroutes

tests/test_askrene.py:737–896  ·  view source on GitHub ↗

Test getroutes call

(node_factory)

Source from the content-addressed store, hash-verified

735
736
737def test_getroutes(node_factory):
738 """Test getroutes call"""
739 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000)),
740 GenChannel(0, 2, capacity_sats=9000),
741 GenChannel(1, 3, forward=GenChannel.Half(propfee=20000)),
742 GenChannel(0, 2, capacity_sats=10000),
743 GenChannel(2, 4, forward=GenChannel.Half(delay=2000))])
744
745 # Set up l1 with this as the gossip_store
746 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
747
748 # Too much should give a decent explanation.
749 dir01 = direction(nodemap[0], nodemap[1])
750 with pytest.raises(RpcError, match=rf"We could not find a usable set of paths\. The shortest path is 0x1x0, but 0x1x0/{dir01} isn't big enough to carry 1000000001msat\."):
751 l1.rpc.getroutes(source=nodemap[0],
752 destination=nodemap[1],
753 amount_msat=1000000001,
754 layers=[],
755 maxfee_msat=100000000,
756 final_cltv=99)
757
758 # This should tell us source doesn't have enough.
759 with pytest.raises(RpcError, match=r"We could not find a usable set of paths\. Total source capacity is only 1019000000msat \(in 3 channels\)\."):
760 l1.rpc.getroutes(source=nodemap[0],
761 destination=nodemap[1],
762 amount_msat=2000000001,
763 layers=[],
764 maxfee_msat=20000000,
765 final_cltv=99)
766
767 # This should tell us dest doesn't have enough.
768 with pytest.raises(RpcError, match=r"We could not find a usable set of paths\. Total destination capacity is only 1000000000msat \(in 1 channels\)\."):
769 l1.rpc.getroutes(source=nodemap[0],
770 destination=nodemap[4],
771 amount_msat=1000000001,
772 layers=[],
773 maxfee_msat=30000000,
774 final_cltv=99)
775
776 # Disabling channels makes getroutes fail
777 dir01 = direction(nodemap[0], nodemap[1])
778 l1.rpc.askrene_create_layer('chans_disabled')
779 l1.rpc.askrene_update_channel(layer="chans_disabled",
780 short_channel_id_dir=f'0x1x0/{dir01}',
781 enabled=False)
782 with pytest.raises(RpcError, match=rf"We could not find a usable set of paths\. The shortest path is 0x1x0, but 0x1x0/{dir01} marked disabled by layer chans_disabled\."):
783 l1.rpc.getroutes(source=nodemap[0],
784 destination=nodemap[1],
785 amount_msat=1000,
786 layers=["chans_disabled"],
787 maxfee_msat=1000,
788 final_cltv=99)
789
790 # Start easy
791 dir01 = direction(nodemap[0], nodemap[1])
792 assert l1.rpc.getroutes(source=nodemap[0],
793 destination=nodemap[1],
794 amount_msat=1000,

Callers

nothing calls this directly

Calls 6

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
check_getroute_pathsFunction · 0.85
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45

Tested by

no test coverage detected