Skip to content

Commit

Permalink
pytest: always override estimatesmartfee.
Browse files Browse the repository at this point in the history
It (almost?) always fails for regtest; best to override it directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Aug 22, 2018
1 parent 8aa53bc commit 7399716
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,15 @@ def bitcoind_cmd_remove_override(self, cmd=None):
failfile = "bitcoin-cli-fail"
os.remove(os.path.join(self.daemon.lightning_dir, failfile))

# Note: this feeds through the smoother in update_feerate, so changing
# it on a running daemon may not give expected result!
def set_feerates(self, feerates, wait_for_effect=True):
# (bitcoind returns bitcoin per kb, so these are * 4)
self.bitcoind_cmd_override("""case "$*" in *2\ CONSERVATIVE*) FEERATE={};; *4\ ECONOMICAL*) FEERATE={};; *100\ ECONOMICAL*) FEERATE={};; *) exit 98;; esac; echo '{{ "feerate": '$(printf 0.%08u $FEERATE)' }}'; exit 0""".format(feerates[0] * 4, feerates[1] * 4, feerates[2] * 4),
'estimatesmartfee')
if wait_for_effect:
self.daemon.wait_for_log('Feerate estimate for .* set to')


class NodeFactory(object):
"""A factory to setup and start `lightningd` daemons.
Expand Down Expand Up @@ -673,7 +682,7 @@ def get_nodes(self, num_nodes, opts=None):

return [j.result() for j in jobs]

def get_node(self, disconnect=None, options=None, may_fail=False, may_reconnect=False, random_hsm=False):
def get_node(self, disconnect=None, options=None, may_fail=False, may_reconnect=False, random_hsm=False, feerates=(15000, 7500, 3750)):
with self.lock:
node_id = self.next_id
self.next_id += 1
Expand Down Expand Up @@ -722,6 +731,10 @@ def get_node(self, disconnect=None, options=None, may_fail=False, may_reconnect=

node = LightningNode(daemon, rpc, self.bitcoind, self.executor, may_fail=may_fail,
may_reconnect=may_reconnect)

# Regtest estimatefee are unusable, so override.
node.set_feerates(feerates, False)

self.nodes.append(node)
if VALGRIND:
node.daemon.cmd_prefix = [
Expand Down

0 comments on commit 7399716

Please sign in to comment.