From 748d91dd7af49f5e74138e2c7165e950dc408f4f Mon Sep 17 00:00:00 2001 From: dustinface <35775977+xdustinface@users.noreply.github.com> Date: Mon, 9 Nov 2020 22:58:49 +0100 Subject: [PATCH] test: Add and use DashTestFramework.get_recovered_sig (#3801) * test: Introduce DashTestFramework.get_recovered_sig * test: Use DashTestFramework.get_recovered_sig --- .../feature_llmq_is_cl_conflicts.py | 24 ++----------------- .../test_framework/test_framework.py | 13 ++++++++++ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/test/functional/feature_llmq_is_cl_conflicts.py b/test/functional/feature_llmq_is_cl_conflicts.py index ea820ec4bb..34ec63b803 100755 --- a/test/functional/feature_llmq_is_cl_conflicts.py +++ b/test/functional/feature_llmq_is_cl_conflicts.py @@ -280,17 +280,7 @@ class LLMQ_IS_CL_Conflicts(DashTestFramework): for mn in self.mninfo: mn.node.quorum('sign', 100, request_id, message_hash) - recSig = None - - t = time.time() - while time.time() - t < 10: - try: - recSig = self.nodes[0].quorum('getrecsig', 100, request_id, message_hash) - break - except: - time.sleep(0.1) - assert(recSig is not None) - + recSig = self.get_recovered_sig(request_id, message_hash) clsig = msg_clsig(height, blockHash, hex_str_to_bytes(recSig['sig'])) return clsig @@ -309,17 +299,7 @@ class LLMQ_IS_CL_Conflicts(DashTestFramework): for mn in self.mninfo: mn.node.quorum('sign', 100, request_id, message_hash) - recSig = None - - t = time.time() - while time.time() - t < 10: - try: - recSig = self.nodes[0].quorum('getrecsig', 100, request_id, message_hash) - break - except: - time.sleep(0.1) - assert(recSig is not None) - + recSig = self.get_recovered_sig(request_id, message_hash) islock = msg_islock(inputs, tx.sha256, hex_str_to_bytes(recSig['sig'])) return islock diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 3375f4b17f..81d9293234 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -977,6 +977,19 @@ class DashTestFramework(BitcoinTestFramework): return new_quorum + def get_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100, node=None): + node = self.nodes[0] if node is None else node + rec_sig = None + time_start = time.time() + while time.time() - time_start < 10: + try: + rec_sig = node.quorum('getrecsig', llmq_type, rec_sig_id, rec_sig_msg_hash) + break + except JSONRPCException: + time.sleep(0.1) + assert(rec_sig is not None) + return rec_sig + def get_quorum_masternodes(self, q): qi = self.nodes[0].quorum('info', 100, q) result = []