Test getroutes call
(node_factory)
| 688 | |
| 689 | |
| 690 | def test_getroutes(node_factory): |
| 691 | """Test getroutes call""" |
| 692 | gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000)), |
| 693 | GenChannel(0, 2, capacity_sats=9000), |
| 694 | GenChannel(1, 3, forward=GenChannel.Half(propfee=20000)), |
| 695 | GenChannel(0, 2, capacity_sats=10000), |
| 696 | GenChannel(2, 4, forward=GenChannel.Half(delay=2000))]) |
| 697 | |
| 698 | # Set up l1 with this as the gossip_store |
| 699 | l1 = node_factory.get_node(gossip_store_file=gsfile.name) |
| 700 | |
| 701 | # Too much should give a decent explanation. |
| 702 | dir01 = direction(nodemap[0], nodemap[1]) |
| 703 | 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\."): |
| 704 | l1.rpc.getroutes(source=nodemap[0], |
| 705 | destination=nodemap[1], |
| 706 | amount_msat=1000000001, |
| 707 | layers=[], |
| 708 | maxfee_msat=100000000, |
| 709 | final_cltv=99) |
| 710 | |
| 711 | # This should tell us source doesn't have enough. |
| 712 | with pytest.raises(RpcError, match=r"We could not find a usable set of paths\. Total source capacity is only 1019000000msat \(in 3 channels\)\."): |
| 713 | l1.rpc.getroutes(source=nodemap[0], |
| 714 | destination=nodemap[1], |
| 715 | amount_msat=2000000001, |
| 716 | layers=[], |
| 717 | maxfee_msat=20000000, |
| 718 | final_cltv=99) |
| 719 | |
| 720 | # This should tell us dest doesn't have enough. |
| 721 | with pytest.raises(RpcError, match=r"We could not find a usable set of paths\. Total destination capacity is only 1000000000msat \(in 1 channels\)\."): |
| 722 | l1.rpc.getroutes(source=nodemap[0], |
| 723 | destination=nodemap[4], |
| 724 | amount_msat=1000000001, |
| 725 | layers=[], |
| 726 | maxfee_msat=30000000, |
| 727 | final_cltv=99) |
| 728 | |
| 729 | # Disabling channels makes getroutes fail |
| 730 | dir01 = direction(nodemap[0], nodemap[1]) |
| 731 | l1.rpc.askrene_create_layer('chans_disabled') |
| 732 | l1.rpc.askrene_update_channel(layer="chans_disabled", |
| 733 | short_channel_id_dir=f'0x1x0/{dir01}', |
| 734 | enabled=False) |
| 735 | 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\."): |
| 736 | l1.rpc.getroutes(source=nodemap[0], |
| 737 | destination=nodemap[1], |
| 738 | amount_msat=1000, |
| 739 | layers=["chans_disabled"], |
| 740 | maxfee_msat=1000, |
| 741 | final_cltv=99) |
| 742 | |
| 743 | # Start easy |
| 744 | dir01 = direction(nodemap[0], nodemap[1]) |
| 745 | assert l1.rpc.getroutes(source=nodemap[0], |
| 746 | destination=nodemap[1], |
| 747 | amount_msat=1000, |
nothing calls this directly
no test coverage detected