(node_factory, executor)
| 3318 | |
| 3319 | @pytest.mark.developer("need dev-feerate, dev-fast-reconnect") |
| 3320 | def test_feerate_stress(node_factory, executor): |
| 3321 | # Third node makes HTLC traffic less predictable. |
| 3322 | l1, l2, l3 = node_factory.line_graph(3, opts={'commit-time': 100, |
| 3323 | 'may_reconnect': True, |
| 3324 | 'dev-fast-reconnect': None}) |
| 3325 | |
| 3326 | l1.pay(l2, 10**9 // 2) |
| 3327 | scid12 = l1.get_channel_scid(l2) |
| 3328 | scid23 = l2.get_channel_scid(l3) |
| 3329 | |
| 3330 | routel1l3 = [{'amount_msat': '10002msat', 'id': l2.info['id'], 'delay': 11, 'channel': scid12}, |
| 3331 | {'amount_msat': '10000msat', 'id': l3.info['id'], 'delay': 5, 'channel': scid23}] |
| 3332 | routel2l1 = [{'amount_msat': '10000msat', 'id': l1.info['id'], 'delay': 5, 'channel': scid12}] |
| 3333 | |
| 3334 | rate = 1875 |
| 3335 | NUM_ATTEMPTS = 25 |
| 3336 | l1done = 0 |
| 3337 | l2done = 0 |
| 3338 | prev_log = 0 |
| 3339 | while l1done < NUM_ATTEMPTS and l2done < NUM_ATTEMPTS: |
| 3340 | try: |
| 3341 | r = random.randrange(6) |
| 3342 | if r == 5: |
| 3343 | l1.rpc.sendpay(routel1l3, "{:064x}".format(l1done)) |
| 3344 | l1done += 1 |
| 3345 | elif r == 4: |
| 3346 | l2.rpc.sendpay(routel2l1, "{:064x}".format(l2done)) |
| 3347 | l2done += 1 |
| 3348 | elif r > 0: |
| 3349 | l1.rpc.call('dev-feerate', [l2.info['id'], rate]) |
| 3350 | rate += 5 |
| 3351 | else: |
| 3352 | l2.rpc.disconnect(l1.info['id'], True) |
| 3353 | time.sleep(1) |
| 3354 | except RpcError: |
| 3355 | time.sleep(0.01) |
| 3356 | assert not l1.daemon.is_in_log('Bad.*signature', start=prev_log) |
| 3357 | prev_log = len(l1.daemon.logs) |
| 3358 | |
| 3359 | # Make sure it's reconnected, and wait for last payment. |
| 3360 | wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected']) |
| 3361 | # We can get TEMPORARY_CHANNEL_FAILURE due to disconnect, too. |
| 3362 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3363 | l1.rpc.waitsendpay("{:064x}".format(l1done - 1)) |
| 3364 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3365 | l2.rpc.waitsendpay("{:064x}".format(l2done - 1)) |
| 3366 | l1.rpc.call('dev-feerate', [l2.info['id'], rate - 5]) |
| 3367 | assert not l1.daemon.is_in_log('Bad.*signature') |
| 3368 | assert not l2.daemon.is_in_log('Bad.*signature') |
| 3369 | |
| 3370 | |
| 3371 | @pytest.mark.developer("need dev_disconnect") |
nothing calls this directly
no test coverage detected