Onchain handling when we've had a range of fees
(node_factory, bitcoind, executor)
| 3076 | |
| 3077 | |
| 3078 | def test_onchain_different_fees(node_factory, bitcoind, executor): |
| 3079 | """Onchain handling when we've had a range of fees""" |
| 3080 | l1, l2 = node_factory.line_graph(2, fundchannel=True, fundamount=10**7, |
| 3081 | opts={'may_reconnect': True}) |
| 3082 | |
| 3083 | l2.rpc.dev_ignore_htlcs(id=l1.info['id'], ignore=True) |
| 3084 | p1 = executor.submit(l1.pay, l2, 1000000000) |
| 3085 | l2.daemon.wait_for_log('htlc 0: SENT_ADD_ACK_COMMIT->RCVD_ADD_ACK_REVOCATION') |
| 3086 | |
| 3087 | l1.set_feerates((16000, 11000, 7500, 3750)) |
| 3088 | p2 = executor.submit(l1.pay, l2, 900000000) |
| 3089 | l2.daemon.wait_for_log('htlc 1: SENT_ADD_ACK_COMMIT->RCVD_ADD_ACK_REVOCATION') |
| 3090 | |
| 3091 | # Restart with different feerate for second HTLC. |
| 3092 | l1.stop() |
| 3093 | l1.set_feerates((5000, 5000, 5000, 5000), wait_for_effect=False) |
| 3094 | l1.start() |
| 3095 | l1.daemon.wait_for_log('peer_out WIRE_UPDATE_FEE') |
| 3096 | |
| 3097 | p3 = executor.submit(l1.pay, l2, 800000000) |
| 3098 | l2.daemon.wait_for_log('htlc 2: SENT_ADD_ACK_COMMIT->RCVD_ADD_ACK_REVOCATION') |
| 3099 | |
| 3100 | # Drop to chain |
| 3101 | l1.rpc.dev_fail(l2.info['id']) |
| 3102 | l1.wait_for_channel_onchain(l2.info['id']) |
| 3103 | |
| 3104 | bitcoind.generate_block(1) |
| 3105 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 3106 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 3107 | |
| 3108 | # Elements still uses non-anchor version. |
| 3109 | if 'anchors/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']: |
| 3110 | expected = {'min_possible_feerate': 3750, |
| 3111 | 'max_possible_feerate': 5005} |
| 3112 | else: |
| 3113 | expected = {'min_possible_feerate': 5005, |
| 3114 | 'max_possible_feerate': 11005} |
| 3115 | |
| 3116 | # Both sides should have correct feerate |
| 3117 | assert l1.db_query('SELECT min_possible_feerate, max_possible_feerate FROM channels;') == [expected] |
| 3118 | |
| 3119 | assert l2.db_query('SELECT min_possible_feerate, max_possible_feerate FROM channels;') == [expected] |
| 3120 | |
| 3121 | bitcoind.generate_block(5) |
| 3122 | |
| 3123 | # We will, over the next few blocks, spend the to-us and the HTLCs. |
| 3124 | # We don't have enough outputs, so the results are a bit random, |
| 3125 | # but we will make progress every block! |
| 3126 | mark = l1.daemon.logsearch_start |
| 3127 | |
| 3128 | r = re.compile('sendrawtx exit 0') |
| 3129 | |
| 3130 | def count_successful_txs(): |
| 3131 | l1.daemon.logs_catchup() |
| 3132 | return sum([r.search(l) is not None for l in l1.daemon.logs[mark:]]) |
| 3133 | |
| 3134 | # First iteration we expect one HTLC-tx and the to-us, then two more htlc txs |
| 3135 | num_successful = 1 |
nothing calls this directly
no test coverage detected