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

Function test_rbf_fails_to_broadcast

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

Source from the content-addressed store, hash-verified

1340@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
1341@pytest.mark.openchannel('v2')
1342def test_rbf_fails_to_broadcast(node_factory, bitcoind, chainparams):
1343 l1, l2 = node_factory.get_nodes(2,
1344 opts={'allow_warning': True,
1345 'may_reconnect': True})
1346
1347 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1348 amount = 2**24
1349 chan_amount = 100000
1350 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['p2tr'], amount / 10**8 + 0.01)
1351 bitcoind.generate_block(1)
1352 # Wait for it to arrive.
1353 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
1354
1355 # Really low feerate means that the bump wont work the first time
1356 res = l1.rpc.fundchannel(l2.info['id'], chan_amount, feerate='253perkw')
1357 chan_id = res['channel_id']
1358 vins = bitcoind.rpc.decoderawtransaction(res['tx'])['vin']
1359 assert(only_one(vins))
1360 prev_utxos = ["{}:{}".format(vins[0]['txid'], vins[0]['vout'])]
1361
1362 # Check that we're waiting for lockin
1363 l1.daemon.wait_for_log(' to DUALOPEND_AWAITING_LOCKIN')
1364 inflights = only_one(l1.rpc.listpeerchannels()['channels'])['inflight']
1365 assert inflights[-1]['funding_txid'] in bitcoind.rpc.getrawmempool()
1366
1367 def run_retry():
1368 startweight = 42 + 173
1369 rate = int(find_next_feerate(l1, l2)[:-5])
1370 # We 2x the feerate to beat the min-relay fee
1371 next_feerate = '{}perkw'.format(rate * 2)
1372 initpsbt = l1.rpc.utxopsbt(chan_amount, next_feerate, startweight,
1373 prev_utxos, reservedok=True,
1374 excess_as_change=True)
1375
1376 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
1377 bump = l1.rpc.openchannel_bump(chan_id, chan_amount,
1378 initpsbt['psbt'],
1379 funding_feerate=next_feerate)
1380 # We should be able to call this with while an open is progress
1381 # but not yet committed
1382 l1.rpc.dev_sign_last_tx(l2.info['id'])
1383 update = l1.rpc.openchannel_update(chan_id, bump['psbt'])
1384 assert update['commitments_secured']
1385
1386 return l1.rpc.signpsbt(update['psbt'])['signed_psbt']
1387
1388 signed_psbt = run_retry()
1389 l1.rpc.openchannel_signed(chan_id, signed_psbt)
1390 inflights = only_one(l1.rpc.listpeerchannels()['channels'])['inflight']
1391 assert inflights[-1]['funding_txid'] in bitcoind.rpc.getrawmempool()
1392
1393 # Restart and listpeers, used to crash
1394 l1.restart()
1395 l1.rpc.listpeers()
1396
1397 # We've restarted. Let's RBF
1398 signed_psbt = run_retry()
1399 l1.rpc.openchannel_signed(chan_id, signed_psbt)

Callers

nothing calls this directly

Calls 15

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
listpeerchannelsMethod · 0.80
openchannel_signedMethod · 0.80
restartMethod · 0.80
dev_sign_last_txMethod · 0.80
connectMethod · 0.45
newaddrMethod · 0.45

Tested by

no test coverage detected