(node_factory, executor)
| 3502 | |
| 3503 | |
| 3504 | def test_feerate_stress(node_factory, executor): |
| 3505 | # Third node makes HTLC traffic less predictable. |
| 3506 | l1, l2, l3 = node_factory.line_graph(3, opts={'commit-time': 100, |
| 3507 | 'may_reconnect': True, |
| 3508 | 'dev-fast-reconnect': None}) |
| 3509 | |
| 3510 | l1.pay(l2, 10**9 // 2) |
| 3511 | scid12 = l1.get_channel_scid(l2) |
| 3512 | scid23 = l2.get_channel_scid(l3) |
| 3513 | |
| 3514 | routel1l3 = [{'amount_msat': '10002msat', 'id': l2.info['id'], 'delay': 11, 'channel': scid12}, |
| 3515 | {'amount_msat': '10000msat', 'id': l3.info['id'], 'delay': 5, 'channel': scid23}] |
| 3516 | routel2l1 = [{'amount_msat': '10000msat', 'id': l1.info['id'], 'delay': 5, 'channel': scid12}] |
| 3517 | |
| 3518 | rate = 1875 |
| 3519 | NUM_ATTEMPTS = 25 |
| 3520 | l1done = 0 |
| 3521 | l2done = 0 |
| 3522 | prev_log = 0 |
| 3523 | while l1done < NUM_ATTEMPTS and l2done < NUM_ATTEMPTS: |
| 3524 | try: |
| 3525 | r = random.randrange(6) |
| 3526 | if r == 5: |
| 3527 | l1.rpc.sendpay(routel1l3, "{:064x}".format(l1done)) |
| 3528 | l1done += 1 |
| 3529 | elif r == 4: |
| 3530 | l2.rpc.sendpay(routel2l1, "{:064x}".format(l2done)) |
| 3531 | l2done += 1 |
| 3532 | elif r > 0: |
| 3533 | l1.rpc.call('dev-feerate', [l2.info['id'], rate]) |
| 3534 | rate += 5 |
| 3535 | else: |
| 3536 | l2.rpc.disconnect(l1.info['id'], True) |
| 3537 | time.sleep(1) |
| 3538 | except RpcError: |
| 3539 | time.sleep(0.01) |
| 3540 | assert not l1.daemon.is_in_log('Bad.*signature', start=prev_log) |
| 3541 | prev_log = len(l1.daemon.logs) |
| 3542 | |
| 3543 | # Wait for last payment |
| 3544 | # We can get TEMPORARY_CHANNEL_FAILURE due to disconnect, too. |
| 3545 | if l1done != 0: |
| 3546 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3547 | l1.rpc.waitsendpay("{:064x}".format(l1done - 1), timeout=TIMEOUT) |
| 3548 | if l2done != 0: |
| 3549 | with pytest.raises(RpcError, match='WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS|WIRE_TEMPORARY_CHANNEL_FAILURE'): |
| 3550 | l2.rpc.waitsendpay("{:064x}".format(l2done - 1), timeout=TIMEOUT) |
| 3551 | |
| 3552 | # Make sure it's reconnected, then try adjusting feerates |
| 3553 | wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] and l2.rpc.getpeer(l1.info['id'])['connected']) |
| 3554 | |
| 3555 | l1.rpc.call('dev-feerate', [l2.info['id'], rate - 5]) |
| 3556 | time.sleep(1) |
| 3557 | |
| 3558 | assert not l1.daemon.is_in_log('Bad.*signature') |
| 3559 | assert not l2.daemon.is_in_log('Bad.*signature') |
| 3560 | |
| 3561 |
nothing calls this directly
no test coverage detected