From 341f9406645dd26c7862ae7abe28aed5c7e9185d Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Thu, 5 Sep 2024 13:25:34 +0100 Subject: [PATCH] func test: prevent disconnects when using mocktime Thanks to pythcoiner for providing this fix. --- tests/test_framework/bitcoind.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_framework/bitcoind.py b/tests/test_framework/bitcoind.py index 95ae04578..a8a49b7ee 100644 --- a/tests/test_framework/bitcoind.py +++ b/tests/test_framework/bitcoind.py @@ -72,6 +72,12 @@ def __init__(self, bitcoin_dir, rpcport=None): "rpcport": rpcport, "fallbackfee": Decimal(1000) / COIN, "rpcthreads": 32, + # bitcoind uses mocktime in some tests, which can lead to peers (e.g. electrs) + # being disconnected. To prevent this, we set `peertimeout` greater than + # the max value being mocked. + # See https://github.com/bitcoin/bitcoin/blob/fa05ee0517d58b600f0ccad4c02c0734a23707d6/src/net.cpp#L1961. + # h/t pythcoiner :) + "peertimeout": 2 * 24 * 60 * 60, # 2 days } self.conf_file = os.path.join(bitcoin_dir, "bitcoin.conf") with open(self.conf_file, "w") as f: