(node_factory, bitcoind)
| 3201 | |
| 3202 | |
| 3203 | def setup_multihtlc_test(node_factory, bitcoind): |
| 3204 | # l1 --\ /-> l6 |
| 3205 | # v / |
| 3206 | # l2 -> l4 -> l5 -> l7 |
| 3207 | # ^ |
| 3208 | # l3 --/ |
| 3209 | # l1 and l7 ignore and HTLCs they're sent. |
| 3210 | # For each direction, we create these HTLCs with same payment_hash: |
| 3211 | # 1 failed (CLTV1) |
| 3212 | # 1 failed (CLTV2) |
| 3213 | # 2 live (CLTV2) |
| 3214 | # 1 live (CLTV3) |
| 3215 | l1, l2, l3, l4, l5, l6, l7 = node_factory.get_nodes(7, |
| 3216 | opts={'dev-no-reconnect': None, |
| 3217 | 'may_reconnect': True}) |
| 3218 | |
| 3219 | l4.fundwallet(10**6 * 4 + 100000) |
| 3220 | l5.fundwallet(10**6 * 2 + 100000) |
| 3221 | |
| 3222 | # They need to be connected. |
| 3223 | for n in l1, l2, l3, l5: |
| 3224 | l4.rpc.connect(n.info['id'], 'localhost', n.port) |
| 3225 | for n in l6, l7: |
| 3226 | l5.rpc.connect(n.info['id'], 'localhost', n.port) |
| 3227 | |
| 3228 | # Efficient way to establish the channels. |
| 3229 | l4.rpc.multifundchannel([{'id': l1.info['id'], 'amount': 10**6}, |
| 3230 | {'id': l2.info['id'], 'amount': 10**6}, |
| 3231 | {'id': l3.info['id'], 'amount': 10**6}, |
| 3232 | {'id': l5.info['id'], 'amount': 10**6}]) |
| 3233 | l5.rpc.multifundchannel([{'id': l6.info['id'], 'amount': 10**6}, |
| 3234 | {'id': l7.info['id'], 'amount': 10**6}]) |
| 3235 | |
| 3236 | # Make sure they're all in normal state. |
| 3237 | bitcoind.generate_block(1) |
| 3238 | wait_for(lambda: all([only_one(l4.rpc.listpeerchannels(p["id"])['channels'])['state'] == 'CHANNELD_NORMAL' |
| 3239 | for p in l4.rpc.listpeers()['peers']])) |
| 3240 | wait_for(lambda: all([only_one(l5.rpc.listpeerchannels(p["id"])['channels'])['state'] == 'CHANNELD_NORMAL' |
| 3241 | for p in l5.rpc.listpeers()['peers']])) |
| 3242 | |
| 3243 | # Balance them |
| 3244 | for n in l1, l2, l3, l5: |
| 3245 | l4.pay(n, 10**9 // 2) |
| 3246 | for n in l6, l7: |
| 3247 | l5.pay(n, 10**9 // 2) |
| 3248 | |
| 3249 | def route_to_l7(src): |
| 3250 | """Route from l1, l2 or l3 to l7""" |
| 3251 | # We give extra CLTV on first hop, so we never break channel. |
| 3252 | return [{'id': l4.info['id'], 'channel': src.get_channel_scid(l4), 'amount_msat': "100002002msat", 'delay': 115}, |
| 3253 | {'id': l5.info['id'], 'channel': l4.get_channel_scid(l5), 'amount_msat': "100001001msat", 'delay': 15}, |
| 3254 | {'id': l7.info['id'], 'channel': l5.get_channel_scid(l7), 'amount_msat': "100000000msat", 'delay': 9}] |
| 3255 | |
| 3256 | def route_to_l1(src): |
| 3257 | """Route from l6 or l7 to l1""" |
| 3258 | # We give extra CLTV on first hop, so we never break channel. |
| 3259 | return [{'id': l5.info['id'], 'channel': src.get_channel_scid(l5), 'amount_msat': "100002002msat", 'delay': 115}, |
| 3260 | {'id': l4.info['id'], 'channel': l5.get_channel_scid(l4), 'amount_msat': "100001001msat", 'delay': 15}, |
no test coverage detected