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

Function test_v2_rbf_single

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

Source from the content-addressed store, hash-verified

245@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
246@pytest.mark.openchannel('v2')
247def test_v2_rbf_single(node_factory, bitcoind, chainparams):
248 l1, l2 = node_factory.get_nodes(2, opts={'wumbo': None})
249
250 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
251 amount = 2**24
252 chan_amount = 100000
253 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
254 bitcoind.generate_block(1)
255 # Wait for it to arrive.
256 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
257
258 res = l1.rpc.fundchannel(l2.info['id'], chan_amount)
259 chan_id = res['channel_id']
260 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
261 assert(only_one(vins))
262 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
263
264 # Check that we're waiting for lockin
265 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
266
267 next_feerate = find_next_feerate(l1, l2)
268
269 # Check that feerate info is correct
270 info_1 = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])
271 assert info_1['initial_feerate'] == info_1['last_feerate']
272 rate = int(info_1['last_feerate'][:-5])
273 assert int(info_1['next_feerate'][:-5]) == rate * 65 // 64
274
275 # Initiate an RBF
276 startweight = 42 + 172 # base weight, funding output
277 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
278 prev_utxos, reservedok=True,
279 min_witness_weight=110,
280 excess_as_change=True)
281
282 # Do the bump
283 bump = l1.rpc.openchannel_bump(chan_id, chan_amount, initpsbt['psbt'])
284
285 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
286 assert update['commitments_secured']
287
288 # Check that feerate info has incremented
289 info_2 = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])
290 assert info_1['initial_feerate'] == info_2['initial_feerate']
291 assert info_1['next_feerate'] == info_2['last_feerate']
292
293 rate = int(info_2['last_feerate'][:-5])
294 assert int(info_2['next_feerate'][:-5]) == rate * 65 // 64
295
296 # Sign our inputs, and continue
297 signed_psbt = l1.rpc.signpsbt(update['psbt'])['signed_psbt']
298
299 # Fails because we didn't put enough feerate in.
300 with pytest.raises(RpcError, match=r'insufficient fee'):
301 l1.rpc.openchannel_signed(chan_id, signed_psbt)
302
303 # Do it again, with a higher feerate
304 info_2 = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])

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

Tested by

no test coverage detected