(node_factory, executor)
| 3453 | |
| 3454 | |
| 3455 | def test_feerate_stress(node_factory, executor): |
| 3456 | # Third node makes HTLC traffic less predictable. |
| 3457 | l1, l2, l3 = node_factory.line_graph(3, opts={'commit-time': 100, |
| 3458 | 'may_reconnect': True, |
| 3459 | 'dev-fast-reconnect': None}) |
| 3460 | |
| 3461 | l1.pay(l2, 10**9 // 2) |
| 3462 | scid12 = l1.get_channel_scid(l2) |
| 3463 | scid23 = l2.get_channel_scid(l3) |
| 3464 | |
| 3465 | routel1l3 = [{'amount_msat': '10002msat', 'id': l2.info['id'], 'delay': 11, 'channel': scid12}, |
| 3466 | {'amount_msat': '10000msat', 'id': l3.info['id'], 'delay': 5, 'channel': scid23}] |
| 3467 | routel2l1 = [{'amount_msat': '10000msat', 'id': l1.info['id'], 'delay': 5, 'channel': scid12}] |
| 3468 | |
| 3469 | rate = 1875 |
| 3470 | NUM_ATTEMPTS = 25 |
| 3471 | l1done = 0 |
| 3472 | l2done = 0 |
| 3473 | prev_log = 0 |
| 3474 | while l1done < NUM_ATTEMPTS and l2done < NUM_ATTEMPTS: |
| 3475 | try: |
| 3476 | r = random.randrange(6) |
| 3477 | if r == 5: |
| 3478 | l1.rpc.sendpay(routel1l3, "{:064x}".format(l1done)) |
| 3479 | l1done += 1 |
| 3480 | elif r == 4: |
| 3481 | l2.rpc.sendpay(routel2l1, "{:064x}".format(l2done)) |
| 3482 | l2done += 1 |
| 3483 | elif r > 0: |
| 3484 | l1.rpc.call('dev-feerate', [l2.info['id'], rate]) |
| 3485 | rate += 5 |
| 3486 | else: |
| 3487 | l2.rpc.disconnect(l1.info['id'], True) |
| 3488 | time.sleep(1) |
| 3489 | except RpcError: |
| 3490 | time.sleep(0.01) |
| 3491 | assert not l1.daemon.is_in_log('Bad.*signature', start=prev_log) |
| 3492 | prev_log = len(l1.daemon.logs) |
| 3493 | |
| 3494 | # Wait for last payment |
| 3495 | # We can get TEMPORARY_CHANNEL_FAILURE due to disconnect, too. |
| 3496 | if l1done != 0: |
| 3497 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3498 | l1.rpc.waitsendpay("{:064x}".format(l1done - 1), timeout=TIMEOUT) |
| 3499 | if l2done != 0: |
| 3500 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3501 | l2.rpc.waitsendpay("{:064x}".format(l2done - 1), timeout=TIMEOUT) |
| 3502 | |
| 3503 | # Make sure it's reconnected, then try adjusting feerates |
| 3504 | wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] and l2.rpc.getpeer(l1.info['id'])['connected']) |
| 3505 | |
| 3506 | l1.rpc.call('dev-feerate', [l2.info['id'], rate - 5]) |
| 3507 | time.sleep(1) |
| 3508 | |
| 3509 | assert not l1.daemon.is_in_log('Bad.*signature') |
| 3510 | assert not l2.daemon.is_in_log('Bad.*signature') |
| 3511 | |
| 3512 |
nothing calls this directly
no test coverage detected