Build a diamond, with a cheap route, that is exhausted. The first payment should try that route first, learn it's exhausted, and then succeed over the other leg. The second, unrelated, payment should immediately skip the exhausted leg and go for the more expensive one. ```mermai
(node_factory)
| 6226 | |
| 6227 | |
| 6228 | def diamond_network(node_factory): |
| 6229 | """Build a diamond, with a cheap route, that is exhausted. The |
| 6230 | first payment should try that route first, learn it's exhausted, |
| 6231 | and then succeed over the other leg. The second, unrelated, |
| 6232 | payment should immediately skip the exhausted leg and go for the |
| 6233 | more expensive one. |
| 6234 | |
| 6235 | ```mermaid |
| 6236 | graph LR |
| 6237 | Sender -- "propfee=1" --> Forwarder1 |
| 6238 | Forwarder1 -- "propfee="1\nexhausted --> Recipient |
| 6239 | Sender -- "propfee=1" --> Forwarder2 |
| 6240 | Forwarder2 -- "propfee=5" --> Recipient |
| 6241 | ``` |
| 6242 | """ |
| 6243 | opts = [ |
| 6244 | {'fee-per-satoshi': 0, 'fee-base': 0, # Sender |
| 6245 | 'xpay-handle-pay': False, |
| 6246 | 'allow-deprecated-apis': True}, |
| 6247 | {'fee-per-satoshi': 0, 'fee-base': 0}, # Low fee, but exhausted channel |
| 6248 | {'fee-per-satoshi': 5000, 'fee-base': 0}, # Disincentivize using fw2 |
| 6249 | {'fee-per-satoshi': 0, 'fee-base': 0}, # Recipient |
| 6250 | ] |
| 6251 | |
| 6252 | sender, fw1, fw2, recipient, = node_factory.get_nodes(4, opts=opts) |
| 6253 | |
| 6254 | # And now wire them all up: notice that all channels, except the |
| 6255 | # recipent <> fw1 are created in the direction of the planned |
| 6256 | # from, meaning we won't be able to forward through there, causing |
| 6257 | # a `channel_hint` to be created, disincentivizing usage of this |
| 6258 | # channel on the second payment. |
| 6259 | node_factory.join_nodes( |
| 6260 | [sender, fw2, recipient, fw1], |
| 6261 | wait_for_announce=True, |
| 6262 | announce_channels=True, |
| 6263 | ) |
| 6264 | # And we complete the diamond by adding the edge from sender to fw1 |
| 6265 | node_factory.join_nodes( |
| 6266 | [sender, fw1], |
| 6267 | wait_for_announce=True, |
| 6268 | announce_channels=True |
| 6269 | ) |
| 6270 | return [sender, fw1, fw2, recipient] |
| 6271 | |
| 6272 | |
| 6273 | def test_pay_remember_hint(node_factory): |
no test coverage detected