mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
pytest: fix btcproxy mock logic.
You're supposed to be able to hand mock_rpc either a function to call, or a dict canned response. We never did the latter, and the logic was broken. It was testing the key, not the value for whether it was a dict. And it could never have given a valid response anyway, since it wouldn't know the id to use. So assume it's a successful result. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7a592a2b5c
commit
be8ebf2667
1 changed files with 6 additions and 2 deletions
|
@ -40,9 +40,13 @@ class BitcoinRpcProxy(object):
|
|||
|
||||
# If we have set a mock for this method reply with that instead of
|
||||
# forwarding the request.
|
||||
if method in self.mocks and type(method) == dict:
|
||||
if method in self.mocks and type(self.mocks[method]) == dict:
|
||||
ret = {}
|
||||
ret['id'] = r['id']
|
||||
ret['error'] = None
|
||||
ret['result'] = self.mocks[method]
|
||||
self.mock_counts[method] += 1
|
||||
return self.mocks[method]
|
||||
return ret
|
||||
elif method in self.mocks and callable(self.mocks[method]):
|
||||
self.mock_counts[method] += 1
|
||||
return self.mocks[method](r)
|
||||
|
|
Loading…
Add table
Reference in a new issue