Test the value randomization through shadow routing Note there is a very low (0.5**10) probability that it fails.
(node_factory)
| 46 | |
| 47 | |
| 48 | def 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 | |
| 73 | def test_mpp(node_factory): |
nothing calls this directly
no test coverage detected