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

Function test_rbf_reconnect_ack

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

Source from the content-addressed store, hash-verified

570@pytest.mark.developer("uses dev-disconnect")
571@pytest.mark.openchannel('v2')
572def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
573 disconnects = ['-WIRE_ACK_RBF',
574 '+WIRE_ACK_RBF']
575
576 l1, l2 = node_factory.get_nodes(2,
577 opts=[{'may_reconnect': True},
578 {'disconnect': disconnects,
579 'may_reconnect': True}])
580
581 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
582 amount = 2**24
583 chan_amount = 100000
584 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
585 bitcoind.generate_block(1)
586 # Wait for it to arrive.
587 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
588
589 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
590 chan_id = res['channel_id']
591 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
592 assert(only_one(vins))
593 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
594
595 # Check that we're waiting for lockin
596 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
597
598 next_feerate = find_next_feerate(l1, l2)
599
600 # Initiate an RBF
601 startweight = 42 + 172 # base weight, funding output
602 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
603 prev_utxos, reservedok=True,
604 min_witness_weight=110,
605 excess_as_change=True)
606
607 # Do the bump!?
608 for d in disconnects:
609 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
610 with pytest.raises(RpcError):
611 l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
612 assert l1.rpc.getpeer(l2.info['id']) is not None
613
614 # This should succeed
615 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
616 l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
617
618
619@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

Callers

nothing calls this directly

Calls 13

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
connectMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected