mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 00:24:19 +01:00
pytest: wait until mock is called for set_feerates.
Got a spurious failure in test_no_fee_estimate; we fired too soon from the logs (presumably we raced in on the first response, but estimatesmartfee gets called 3 times). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
d5c3626fa7
commit
e41e1a177e
@@ -29,6 +29,7 @@ class BitcoinRpcProxy(object):
|
|||||||
self.app.add_url_rule("/", "API entrypoint", self.proxy, methods=['POST'])
|
self.app.add_url_rule("/", "API entrypoint", self.proxy, methods=['POST'])
|
||||||
self.rpcport = rpcport
|
self.rpcport = rpcport
|
||||||
self.mocks = {}
|
self.mocks = {}
|
||||||
|
self.mock_counts = {}
|
||||||
self.bitcoind = bitcoind
|
self.bitcoind = bitcoind
|
||||||
self.request_count = 0
|
self.request_count = 0
|
||||||
|
|
||||||
@@ -40,8 +41,10 @@ class BitcoinRpcProxy(object):
|
|||||||
# If we have set a mock for this method reply with that instead of
|
# If we have set a mock for this method reply with that instead of
|
||||||
# forwarding the request.
|
# forwarding the request.
|
||||||
if method in self.mocks and type(method) == dict:
|
if method in self.mocks and type(method) == dict:
|
||||||
|
self.mock_counts[method] += 1
|
||||||
return self.mocks[method]
|
return self.mocks[method]
|
||||||
elif method in self.mocks and callable(self.mocks[method]):
|
elif method in self.mocks and callable(self.mocks[method]):
|
||||||
|
self.mock_counts[method] += 1
|
||||||
return self.mocks[method](r)
|
return self.mocks[method](r)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -100,5 +103,6 @@ class BitcoinRpcProxy(object):
|
|||||||
"""
|
"""
|
||||||
if response is not None:
|
if response is not None:
|
||||||
self.mocks[method] = response
|
self.mocks[method] = response
|
||||||
|
self.mock_counts[method] = 0
|
||||||
elif method in self.mocks:
|
elif method in self.mocks:
|
||||||
del self.mocks[method]
|
del self.mocks[method]
|
||||||
|
|||||||
@@ -627,8 +627,10 @@ class LightningNode(object):
|
|||||||
}
|
}
|
||||||
self.daemon.rpcproxy.mock_rpc('estimatesmartfee', mock_estimatesmartfee)
|
self.daemon.rpcproxy.mock_rpc('estimatesmartfee', mock_estimatesmartfee)
|
||||||
|
|
||||||
|
# Technically, this waits until it's called, not until it's processed.
|
||||||
|
# We wait until all three levels have been called.
|
||||||
if wait_for_effect:
|
if wait_for_effect:
|
||||||
self.daemon.wait_for_log('Feerate estimate for .* set to')
|
wait_for(lambda: self.daemon.rpcproxy.mock_counts['estimatesmartfee'] >= 3)
|
||||||
|
|
||||||
|
|
||||||
class NodeFactory(object):
|
class NodeFactory(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user