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

Function test_shadow_routing

tests/test_renepay.py:48–70  ·  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

46
47
48def test_shadow_routing(node_factory):
49 """
50 Test the value randomization through shadow routing
51
52 Note there is a very low (0.5**10) probability that it fails.
53 """
54 # We need l3 for random walk
55 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,
56 opts={'allow-deprecated-apis': True,
57 'dev-allow-localhost': None})
58
59 amount = 10000
60 total_amount = 0
61 n_payments = 10
62 for i in range(n_payments):
63 inv = l3.rpc.invoice(amount, "{}".format(i), "test")["bolt11"]
64 total_amount += l1.rpc.call(
65 "renepay", {"invstring": inv, "dev_use_shadow": True}
66 )["amount_sent_msat"]
67
68 assert total_amount > n_payments * amount
69 # Test that the added amount isn't absurd
70 assert total_amount < int((n_payments * amount) * (1 + 0.01))
71
72
73def test_mpp(node_factory):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
invoiceMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected