Skip to content

Commit 0374fc1

Browse files
niftyneirustyrussell
authored andcommitted
df tests: node still correctly picks up new tx if broadcast fails
Now that we're more broadcast failure aware, let's check that on actual broadcast failure we still update UTXO set properly and the channel opens.
1 parent 225ff87 commit 0374fc1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_connection.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,47 @@ def mock_donothing(r):
27182718
assert len(l2.rpc.listpeers(l1.info['id'])['peers']) == 0
27192719

27202720

2721+
@pytest.mark.developer("needs --dev-max-funding-unconfirmed-blocks")
2722+
@pytest.mark.openchannel('v2')
2723+
def test_fundee_node_unconfirmed(node_factory, bitcoind):
2724+
"""Test that fundee will successfully broadcast and
2725+
funder still has correct UTXOs/correctly advances the channel
2726+
"""
2727+
# opener
2728+
l1, l2 = node_factory.line_graph(2, fundchannel=False)
2729+
2730+
# Give opener some funds.
2731+
l1.fundwallet(10**7)
2732+
2733+
start_amount = only_one(l1.rpc.listfunds()['outputs'])['amount_msat']
2734+
2735+
def mock_sendrawtransaction(r):
2736+
return {'id': r['id'], 'error': {'code': 100, 'message': 'sendrawtransaction disabled'}}
2737+
2738+
def mock_donothing(r):
2739+
time.sleep(10)
2740+
return bitcoind.rpc.sendrawtransaction(r['params'][0])
2741+
2742+
# Prevent both from broadcasting funding tx (any tx really).
2743+
l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_sendrawtransaction)
2744+
l2.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_donothing)
2745+
2746+
# Fund the channel.
2747+
# The process will complete, but opener will be unable
2748+
# to broadcast and confirm funding tx.
2749+
with pytest.raises(RpcError, match=r'sendrawtransaction disabled'):
2750+
l1.rpc.fundchannel(l2.info['id'], 10**6)
2751+
2752+
# Generate blocks until unconfirmed.
2753+
bitcoind.generate_block(1, wait_for_mempool=1)
2754+
2755+
# Check that l1 opened the channel
2756+
wait_for(lambda: only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['state'] == 'CHANNELD_NORMAL')
2757+
end_amount = only_one(l1.rpc.listfunds()['outputs'])['amount_msat']
2758+
# We should be out the onchaind fees
2759+
assert start_amount > end_amount + Millisatoshi(10 ** 7 * 100)
2760+
2761+
27212762
@pytest.mark.developer("needs dev_fail")
27222763
def test_no_fee_estimate(node_factory, bitcoind, executor):
27232764
l1 = node_factory.get_node(start=False, options={'dev-no-fake-fees': True})

0 commit comments

Comments
 (0)