File dash-core-timeout_factor.patch of Package dash-core

From 2528b7eeaf54bea71c7248196f8e59039105699a Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Tue, 23 May 2023 20:12:22 +0100
Subject: [PATCH] Take timeout_factor into account in many tests.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 test/functional/test_framework/test_framework.py | 13 +++++++++++++
 test/functional/test_framework/test_node.py      |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index ca85a09ddf..fc50cc482a 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -1545,6 +1545,7 @@ class DashTestFramework(BitcoinTestFramework):
         return ret
 
     def wait_for_tx(self, txid, node, expected=True, timeout=60):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_tx():
             try:
                 self.bump_mocktime(1)
@@ -1577,6 +1578,7 @@ class DashTestFramework(BitcoinTestFramework):
         return isdlock
 
     def wait_for_instantlock(self, txid, node, expected=True, timeout=60):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_instantlock():
             self.bump_mocktime(1)
             try:
@@ -1587,6 +1589,7 @@ class DashTestFramework(BitcoinTestFramework):
             raise AssertionError("waiting unexpectedly succeeded")
 
     def wait_for_chainlocked_block(self, node, block_hash, expected=True, timeout=15):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_chainlocked_block():
             try:
                 block = node.getblock(block_hash)
@@ -1601,9 +1604,11 @@ class DashTestFramework(BitcoinTestFramework):
             self.wait_for_chainlocked_block(node, block_hash, expected=expected, timeout=timeout)
 
     def wait_for_best_chainlock(self, node, block_hash, timeout=15):
+        timeout = int(timeout * self.options.timeout_factor)
         wait_until(lambda: node.getbestchainlock()["blockhash"] == block_hash, timeout=timeout, sleep=0.1)
 
     def wait_for_sporks_same(self, timeout=30):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_sporks_same():
             self.bump_mocktime(1)
             sporks = self.nodes[0].spork('show')
@@ -1611,6 +1616,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(check_sporks_same, timeout=timeout, sleep=0.5)
 
     def wait_for_quorum_connections(self, quorum_hash, expected_connections, mninfos, llmq_type_name="llmq_test", timeout = 60, wait_proc=None):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_quorum_connections():
             def ret():
                 if wait_proc is not None:
@@ -1650,6 +1656,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(check_quorum_connections, timeout=timeout, sleep=1)
 
     def wait_for_masternode_probes(self, quorum_hash, mninfos, timeout = 30, wait_proc=None, llmq_type_name="llmq_test"):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_probes():
             def ret():
                 if wait_proc is not None:
@@ -1688,6 +1695,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(check_probes, timeout=timeout, sleep=1)
 
     def wait_for_quorum_phase(self, quorum_hash, phase, expected_member_count, check_received_messages, check_received_messages_count, mninfos, llmq_type_name="llmq_test", timeout=30, sleep=0.5):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_dkg_session():
             member_count = 0
             for mn in mninfos:
@@ -1710,6 +1718,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(check_dkg_session, timeout=timeout, sleep=sleep)
 
     def wait_for_quorum_commitment(self, quorum_hash, nodes, llmq_type=100, timeout=15):
+        timeout = int(timeout * self.options.timeout_factor)
         def check_dkg_comitments():
             for node in nodes:
                 s = node.quorum("dkgstatus")
@@ -1731,6 +1740,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(check_dkg_comitments, timeout=timeout, sleep=1)
 
     def wait_for_quorum_list(self, quorum_hash, nodes, timeout=15, sleep=2, llmq_type_name="llmq_test"):
+        timeout = int(timeout * self.options.timeout_factor)
         def wait_func():
             self.log.info("quorums: " + str(self.nodes[0].quorum("list")))
             if quorum_hash in self.nodes[0].quorum("list")[llmq_type_name]:
@@ -1742,6 +1752,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(wait_func, timeout=timeout, sleep=sleep)
 
     def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test",  timeout=15, sleep=2):
+        timeout = int(timeout * self.options.timeout_factor)
         def wait_func():
             self.log.info("h("+str(self.nodes[0].getblockcount())+") quorums: " + str(self.nodes[0].quorum("list")))
             if quorum_hash_0 in self.nodes[0].quorum("list")[llmq_type_name]:
@@ -2051,6 +2062,7 @@ class DashTestFramework(BitcoinTestFramework):
 
     def wait_for_quorum_data(self, mns, quorum_type_in, quorum_hash_in, test_secret=True, expect_secret=True,
                              recover=False, timeout=60):
+        timeout = int(timeout * self.options.timeout_factor)
         def test_mns():
             valid = 0
             if recover:
@@ -2070,6 +2082,7 @@ class DashTestFramework(BitcoinTestFramework):
         wait_until(test_mns, timeout=timeout, sleep=0.5)
 
     def wait_for_mnauth(self, node, count, timeout=10):
+        timeout = int(timeout * self.options.timeout_factor)
         def test():
             pi = node.getpeerinfo()
             c = 0
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 20bd6b5e93..9e2bf87612 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -248,7 +248,7 @@ class TestNode():
                 if self.version_is_at_least(180000):
                     # getmempoolinfo.loaded is available since commit
                     # 71e38b9ebcb78b3a264a4c25c7c4e373317f2a40 (version 0.18.0)
-                    wait_until(lambda: rpc.getmempoolinfo()['loaded'])
+                    wait_until(lambda: rpc.getmempoolinfo()['loaded'], timeout_factor=self.timeout_factor)
                     # Wait for the node to finish reindex, block import, and
                     # loading the mempool. Usually importing happens fast or
                     # even "immediate" when the node is started. However, there
-- 
2.44.0