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

Function test_rbf_reconnect_tx_construct

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

Source from the content-addressed store, hash-verified

620@pytest.mark.developer("uses dev-disconnect")
621@pytest.mark.openchannel('v2')
622def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
623 disconnects = ['=WIRE_TX_ADD_INPUT', # Initial funding succeeds
624 '-WIRE_TX_ADD_INPUT',
625 '+WIRE_TX_ADD_INPUT',
626 '-WIRE_TX_ADD_OUTPUT',
627 '+WIRE_TX_ADD_OUTPUT',
628 '-WIRE_TX_COMPLETE',
629 '+WIRE_TX_COMPLETE']
630
631 l1, l2 = node_factory.get_nodes(2,
632 opts=[{'disconnect': disconnects,
633 'may_reconnect': True,
634 'dev-no-reconnect': None},
635 {'may_reconnect': True,
636 'dev-no-reconnect': None}])
637
638 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
639 amount = 2**24
640 chan_amount = 100000
641 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
642 bitcoind.generate_block(1)
643 # Wait for it to arrive.
644 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
645
646 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
647 chan_id = res['channel_id']
648 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
649 assert(only_one(vins))
650 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
651
652 # Check that we're waiting for lockin
653 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
654
655 next_feerate = find_next_feerate(l1, l2)
656
657 # Initiate an RBF
658 startweight = 42 + 172 # base weight, funding output
659 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
660 prev_utxos, reservedok=True,
661 min_witness_weight=110,
662 excess_as_change=True)
663
664 # Run through TX_ADD wires
665 for d in disconnects[1:-2]:
666 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
667 with pytest.raises(RpcError):
668 l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
669 wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] is False)
670
671 # Now we finish off the completes failure check
672 for d in disconnects[-2:]:
673 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
674 bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
675 with pytest.raises(RpcError):
676 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
677 wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] is False)
678
679 # Now we succeed

Callers

nothing calls this directly

Calls 14

wait_forFunction · 0.90
only_oneFunction · 0.90
find_next_feerateFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
utxopsbtMethod · 0.80
openchannel_bumpMethod · 0.80
openchannel_updateMethod · 0.80
connectMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45

Tested by

no test coverage detected