mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: Use the mock bitcoind everywhere
This commit is contained in:
@@ -1088,19 +1088,23 @@ def test_fundee_forget_funding_tx_unconfirmed(node_factory, bitcoind):
|
||||
# Let blocks settle.
|
||||
time.sleep(1)
|
||||
|
||||
# Prevent funder from broadcasting funding tx.
|
||||
l1.bitcoind_cmd_override('exit 1')
|
||||
def mock_sendrawtransaction(r):
|
||||
return {'error': 'sendrawtransaction disabled'}
|
||||
|
||||
# Prevent funder from broadcasting funding tx (any tx really).
|
||||
l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_sendrawtransaction)
|
||||
|
||||
# Fund the channel.
|
||||
# The process will complete, but funder will be unable
|
||||
# to broadcast and confirm funding tx.
|
||||
l1.rpc.fundchannel(l2.info['id'], 10**6)
|
||||
# Prevent l1 from timing out bitcoin-cli.
|
||||
l1.bitcoind_cmd_remove_override()
|
||||
|
||||
# Generate blocks until unconfirmed.
|
||||
bitcoind.generate_block(blocks)
|
||||
|
||||
# fundee will forget channel!
|
||||
l2.daemon.wait_for_log('Forgetting channel: It has been {} blocks'.format(blocks))
|
||||
|
||||
# fundee will also forget and disconnect from peer.
|
||||
assert len(l2.rpc.listpeers(l1.info['id'])['peers']) == 0
|
||||
|
||||
|
||||
@@ -89,7 +89,12 @@ def test_bitcoin_failure(node_factory, bitcoind):
|
||||
# Make sure we're not failing it between getblockhash and getblock.
|
||||
sync_blockheight(bitcoind, [l1])
|
||||
|
||||
l1.bitcoind_cmd_override('exit 1')
|
||||
def crash_bitcoincli(r):
|
||||
return {'error': 'go away'}
|
||||
|
||||
# This is not a JSON-RPC response by purpose
|
||||
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', crash_bitcoincli)
|
||||
l1.daemon.rpcproxy.mock_rpc('getblockhash', crash_bitcoincli)
|
||||
|
||||
# This should cause both estimatefee and getblockhash fail
|
||||
l1.daemon.wait_for_logs(['estimatesmartfee .* exited with status 1',
|
||||
@@ -100,7 +105,9 @@ def test_bitcoin_failure(node_factory, bitcoind):
|
||||
'getblockhash .* exited with status 1'])
|
||||
|
||||
# Restore, then it should recover and get blockheight.
|
||||
l1.bitcoind_cmd_remove_override()
|
||||
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', None)
|
||||
l1.daemon.rpcproxy.mock_rpc('getblockhash', None)
|
||||
|
||||
bitcoind.generate_block(5)
|
||||
sync_blockheight(bitcoind, [l1])
|
||||
|
||||
@@ -921,6 +928,8 @@ def test_logging(node_factory):
|
||||
logpath = os.path.join(l1.daemon.lightning_dir, 'logfile')
|
||||
logpath_moved = os.path.join(l1.daemon.lightning_dir, 'logfile_moved')
|
||||
|
||||
l1.daemon.rpcproxy.start()
|
||||
l1.daemon.opts['bitcoin-rpcport'] = l1.daemon.rpcproxy.rpcport
|
||||
TailableProc.start(l1.daemon)
|
||||
wait_for(lambda: os.path.exists(logpath))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user