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

Function test_v2_rbf_single

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

Source from the content-addressed store, hash-verified

524@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
525@pytest.mark.openchannel('v2')
526def test_v2_rbf_single(node_factory, bitcoind, chainparams):
527 l1, l2 = node_factory.get_nodes(2)
528
529 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
530 amount = 2**24
531 chan_amount = 100000
532 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['p2tr'], amount / 10**8 + 0.01)
533 bitcoind.generate_block(1)
534 # Wait for it to arrive.
535 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
536
537 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
538 chan_id = res['channel_id']
539 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
540 assert(only_one(vins))
541 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
542
543 # Check that we're waiting for lockin
544 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
545
546 next_feerate = find_next_feerate(l1, l2)
547
548 # Check that feerate info is correct
549 info_1 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
550 assert info_1['initial_feerate'] == info_1['last_feerate']
551 rate = int(info_1['last_feerate'][:-5])
552 assert int(info_1['next_feerate'][:-5]) == rate * 25 // 24
553
554 # Initiate an RBF
555 startweight = 42 + 172 # base weight, funding output
556 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
557 prev_utxos, reservedok=True,
558 excess_as_change=True)
559
560 # Do the bump
561 bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
562
563 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
564 assert update['commitments_secured']
565
566 # Check that feerate info has incremented
567 info_2 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
568 assert info_1['initial_feerate'] == info_2['initial_feerate']
569 assert info_1['next_feerate'] == info_2['last_feerate']
570
571 rate = int(info_2['last_feerate'][:-5])
572 assert int(info_2['next_feerate'][:-5]) == rate * 25 // 24
573
574 # Sign our inputs, and continue
575 signed_psbt = l1.rpc.signpsbt(update['psbt'])['signed_psbt']
576
577 l1.rpc.openchannel_signed(chan_id, signed_psbt)
578
579 # Do it again, with a higher feerate
580 info_2 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])
581 assert info_1['initial_feerate'] == info_2['initial_feerate']
582 assert info_1['next_feerate'] == info_2['last_feerate']
583 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