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

Function test_shadow_routing

tests/test_pay.py:2942–2962  ·  view source on GitHub ↗

Test the value randomization through shadow routing Note there is a very low (0.5**10) probability that it fails.

(node_factory)

Source from the content-addressed store, hash-verified

2940
2941
2942def test_shadow_routing(node_factory):
2943 """
2944 Test the value randomization through shadow routing
2945
2946 Note there is a very low (0.5**10) probability that it fails.
2947 """
2948 # We need l3 for random walk
2949 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
2950
2951 amount = 10000
2952 total_amount = 0
2953 n_payments = 10
2954 for i in range(n_payments):
2955 inv = l3.rpc.invoice(amount, "{}".format(i), "test")["bolt11"]
2956 total_amount += l1.rpc.pay(inv)["amount_sent_msat"]
2957
2958 assert total_amount > n_payments * amount
2959 # Test that the added amount isn't absurd
2960 assert total_amount < int((n_payments * amount) * (1 + 0.01))
2961
2962 # FIXME: Test cltv delta too ?
2963
2964
2965def test_createonion_rpc(node_factory):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
invoiceMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected