From 2d7c1ed0cfd912eeeed5f3a7561d714ecb654bbc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 23 Jan 2019 12:06:50 +1030 Subject: [PATCH] pytest: create proper mock failures. We actually produce an invalid JSON error at the moment: bitcoin-cli complains "JSON value is not an integer as expected" rather than returning the given error. Make our error a valid JSON RPC error. Signed-off-by: Rusty Russell --- tests/btcproxy.py | 1 + tests/test_connection.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/btcproxy.py b/tests/btcproxy.py index 8b0f64018..72b8c5069 100644 --- a/tests/btcproxy.py +++ b/tests/btcproxy.py @@ -56,6 +56,7 @@ class BitcoinRpcProxy(object): except JSONRPCError as e: reply = { "error": e.error, + "code": -32603, "id": r['id'] } self.request_count += 1 diff --git a/tests/test_connection.py b/tests/test_connection.py index a84c8355e..8ef7028dd 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1112,7 +1112,7 @@ def test_fundee_forget_funding_tx_unconfirmed(node_factory, bitcoind): time.sleep(1) def mock_sendrawtransaction(r): - return {'error': 'sendrawtransaction disabled'} + return {'id': r['id'], 'error': {'code': 100, 'message': 'sendrawtransaction disabled'}} # Prevent funder from broadcasting funding tx (any tx really). l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_sendrawtransaction)