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

Function test_v2_rbf_single

tests/test_opening.py:339–429  ·  view source on GitHub ↗
(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

337@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
338@pytest.mark.openchannel('v2')
339def test_v2_rbf_single(node_factory, bitcoind, chainparams):
340 l1, l2 = node_factory.get_nodes(2)
341
342 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
343 amount = 2**24
344 chan_amount = 100000
345 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['p2tr'], amount / 10**8 + 0.01)
346 bitcoind.generate_block(1)
347 # Wait for it to arrive.
348 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
349
350 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
351 chan_id = res['channel_id']
352 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
353 assert(only_one(vins))
354 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
355
356 # Check that we're waiting for lockin
357 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
358
359 next_feerate = find_next_feerate(l1, l2)
360
361 # Check that feerate info is correct
362 info_1 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
363 assert info_1['initial_feerate'] == info_1['last_feerate']
364 rate = int(info_1['last_feerate'][:-5])
365 assert int(info_1['next_feerate'][:-5]) == rate * 25 // 24
366
367 # Initiate an RBF
368 startweight = 42 + 172 # base weight, funding output
369 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
370 prev_utxos, reservedok=True,
371 excess_as_change=True)
372
373 # Do the bump
374 bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
375
376 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
377 assert update['commitments_secured']
378
379 # Check that feerate info has incremented
380 info_2 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
381 assert info_1['initial_feerate'] == info_2['initial_feerate']
382 assert info_1['next_feerate'] == info_2['last_feerate']
383
384 rate = int(info_2['last_feerate'][:-5])
385 assert int(info_2['next_feerate'][:-5]) == rate * 25 // 24
386
387 # Sign our inputs, and continue
388 signed_psbt = l1.rpc.signpsbt(update['psbt'])['signed_psbt']
389
390 l1.rpc.openchannel_signed(chan_id, signed_psbt)
391
392 # Do it again, with a higher feerate
393 info_2 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
394 assert info_1['initial_feerate'] == info_2['initial_feerate']
395 assert info_1['next_feerate'] == info_2['last_feerate']
396 rate = int(info_2['last_feerate'][:-5])

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
find_next_feerateFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
listpeerchannelsMethod · 0.80
utxopsbtMethod · 0.80
openchannel_bumpMethod · 0.80
openchannel_updateMethod · 0.80
signpsbtMethod · 0.80

Tested by

no test coverage detected