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

Function test_rbf_fails_to_broadcast

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

Source from the content-addressed store, hash-verified

828@pytest.mark.openchannel('v2')
829@pytest.mark.developer("uses dev-sign-last-tx")
830def test_rbf_fails_to_broadcast(node_factory, bitcoind, chainparams):
831 l1, l2 = node_factory.get_nodes(2,
832 opts={'allow_warning': True,
833 'may_reconnect': True})
834
835 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
836 amount = 2**24
837 chan_amount = 100000
838 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
839 bitcoind.generate_block(1)
840 # Wait for it to arrive.
841 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
842
843 # Really low feerate means that the bump wont work the first time
844 res = l1.rpc.fundchannel(l2.info['id'], chan_amount, feerate='253perkw')
845 chan_id = res['channel_id']
846 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
847 assert(only_one(vins))
848 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
849
850 # Check that we're waiting for lockin
851 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
852 inflights = only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['inflight']
853 assert inflights[-1]['funding_txid'] in bitcoind.rpc.getrawmempool()
854
855 def run_retry():
856 startweight = 42 + 173
857 rate = int(find_next_feerate(l1, l2)[:-5])
858 # We 2x the feerate to beat the min-relay fee
859 next_feerate = '{}perkw'.format(rate * 2)
860 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
861 prev_utxos, reservedok=True,
862 min_witness_weight=110,
863 excess_as_change=True)
864
865 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
866 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
867 initpsbt['psbt'],
868 funding_feerate=next_feerate)
869 # We should be able to call this with while an open is progress
870 # but not yet committed
871 l1.rpc.dev_sign_last_tx(l2.info['id'])
872 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
873 assert update['commitments_secured']
874
875 return l1.rpc.signpsbt(update['psbt'])['signed_psbt']
876
877 signed_psbt = run_retry()
878 l1.rpc.openchannel_signed(chan_id, signed_psbt)
879 inflights = only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['inflight']
880 assert inflights[-1]['funding_txid'] in bitcoind.rpc.getrawmempool()
881
882 # Restart and listpeers, used to crash
883 l1.restart()
884 l1.rpc.listpeers()
885
886 # We've restarted. Let's RBF
887 signed_psbt = run_retry()

Callers

nothing calls this directly

Calls 14

wait_forFunction · 0.90
only_oneFunction · 0.90
run_retryFunction · 0.85
get_nodesMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
openchannel_signedMethod · 0.80
restartMethod · 0.80
dev_sign_last_txMethod · 0.80
connectMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45

Tested by

no test coverage detected