MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_closing_different_fees

Function test_closing_different_fees

tests/test_closing.py:207–263  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

205@unittest.skipIf(TEST_NETWORK != 'regtest', 'FIXME: broken under elements')
206@pytest.mark.slow_test
207def test_closing_different_fees(node_factory, bitcoind, executor):
208 l1 = node_factory.get_node()
209
210 # Default feerate = 15000/11000/7500/1000
211 # It will start at the second number, accepting anything above the first.
212 feerates = [[20000, 11000, 15000, 7400], [8000, 6000, 1001, 100]]
213 balance = [False, True]
214 num_peers = len(feerates) * len(balance)
215
216 addr = l1.rpc.newaddr()['p2tr']
217 bitcoind.rpc.sendtoaddress(addr, 1)
218 numfunds = len(l1.rpc.listfunds()['outputs'])
219 bitcoind.generate_block(1)
220 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > numfunds)
221
222 # Create them in a batch, for speed!
223 peers = []
224 for feerate in feerates:
225 for b in balance:
226 p = node_factory.get_node(feerates=feerate)
227 p.feerate = feerate
228 p.balance = b
229 l1.rpc.connect(p.info['id'], 'localhost', p.port)
230 peers.append(p)
231
232 for p in peers:
233 p.channel = l1.rpc.fundchannel(p.info['id'], 10**6, minconf=0)['channel_id']
234 # Technically, this is async to fundchannel returning.
235 l1.daemon.wait_for_log('sendrawtx exit 0')
236
237 mine_funding_to_announce(bitcoind, peers, num_blocks=6)
238
239 # Now wait for them all to hit normal state, do payments
240 l1.daemon.wait_for_logs(['update for channel .* now ACTIVE'] * num_peers
241 + ['to CHANNELD_NORMAL'] * num_peers)
242 for p in peers:
243 if p.balance:
244 l1.pay(p, 100000000)
245
246 # Now close all channels (not unilaterally!)
247 closes = [executor.submit(l1.rpc.close, p.channel, 0) for p in peers]
248
249 for c in closes:
250 c.result(90)
251
252 # close does *not* wait for the sendrawtransaction, so do that!
253 # Note that since they disagree on the ideal fee, they may conflict
254 # (first one in will win), so we cannot look at logs, we need to
255 # wait for mempool.
256 wait_for(lambda: bitcoind.rpc.getmempoolinfo()['size'] == num_peers)
257
258 bitcoind.generate_block(1)
259 for p in peers:
260 p.daemon.wait_for_log(' to ONCHAIN')
261 wait_for(lambda: 'ONCHAIN:Tracking mutual close transaction' in only_one(p.rpc.listpeerchannels(l1.info['id'])['channels'])['status'])
262
263 l1.daemon.wait_for_logs([' to ONCHAIN'] * num_peers)
264

Callers

nothing calls this directly

Calls 13

wait_forFunction · 0.90
mine_funding_to_announceFunction · 0.90
only_oneFunction · 0.90
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
wait_for_logsMethod · 0.80
listpeerchannelsMethod · 0.80
get_nodeMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected