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

Function test_v2_rbf_multi

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

Source from the content-addressed store, hash-verified

427@pytest.mark.developer("uses dev-no-reconnect")
428@pytest.mark.openchannel('v2')
429def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
430 l1, l2 = node_factory.get_nodes(2,
431 opts={'may_reconnect': True,
432 'dev-no-reconnect': None,
433 'allow_warning': True})
434
435 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
436 amount = 2**24
437 chan_amount = 100000
438 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
439 bitcoind.generate_block(1)
440 # Wait for it to arrive.
441 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
442
443 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
444 chan_id = res['channel_id']
445 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
446 assert(only_one(vins))
447 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
448
449 # Check that we're waiting for lockin
450 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
451
452 # Attempt to do abort, should fail since we've
453 # already gotten an inflight
454 with pytest.raises(RpcError):
455 l1.rpc.openchannel_abort(chan_id)
456
457 rate = int(find_next_feerate(l1, l2)[:-5])
458 # We 4x the feerate to beat the min-relay fee
459 next_feerate = '{}perkw'.format(rate * 4)
460
461 # Initiate an RBF
462 startweight = 42 + 172 # base weight, funding output
463 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
464 prev_utxos, reservedok=True,
465 min_witness_weight=110,
466 excess_as_change=True)
467
468 # Do the bump
469 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
470 initpsbt['psbt'],
471 funding_feerate=next_feerate)
472
473 # Abort this open attempt! We will re-try
474 aborted = l1.rpc.openchannel_abort(chan_id)
475 assert not aborted['channel_canceled']
476 wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['connected'] is False)
477
478 # Do the bump, again, same feerate
479 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
480 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
481 initpsbt['psbt'],
482 funding_feerate=next_feerate)
483
484 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
485 assert update['commitments_secured']
486

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
openchannel_abortMethod · 0.80
utxopsbtMethod · 0.80
openchannel_bumpMethod · 0.80
openchannel_updateMethod · 0.80
signpsbtMethod · 0.80

Tested by

no test coverage detected