1616from test_framework .util import assert_equal , assert_raises_rpc_error , force_finish_mnsync
1717
1818
19+ q_type = 100
1920class LLMQSigningTest (DashTestFramework ):
2021 def set_test_params (self ):
2122 self .set_dash_test_params (6 , 5 )
@@ -43,11 +44,11 @@ def run_test(self):
4344
4445 def check_sigs (hasrecsigs , isconflicting1 , isconflicting2 ):
4546 for mn in self .mninfo :
46- if mn .node .quorum ("hasrecsig" , 104 , id , msgHash ) != hasrecsigs :
47+ if mn .node .quorum ("hasrecsig" , q_type , id , msgHash ) != hasrecsigs :
4748 return False
48- if mn .node .quorum ("isconflicting" , 104 , id , msgHash ) != isconflicting1 :
49+ if mn .node .quorum ("isconflicting" , q_type , id , msgHash ) != isconflicting1 :
4950 return False
50- if mn .node .quorum ("isconflicting" , 104 , id , msgHashConflict ) != isconflicting2 :
51+ if mn .node .quorum ("isconflicting" , q_type , id , msgHashConflict ) != isconflicting2 :
5152 return False
5253 return True
5354
@@ -61,24 +62,24 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
6162 wait_for_sigs (False , False , False , 1 )
6263
6364 # Sign first share without any optional parameter, should not result in recovered sig
64- self .mninfo [0 ].node .quorum ("sign" , 104 , id , msgHash )
65+ self .mninfo [0 ].node .quorum ("sign" , q_type , id , msgHash )
6566 assert_sigs_nochange (False , False , False , 3 )
6667 # Sign second share and test optional quorumHash parameter, should not result in recovered sig
6768 # 1. Providing an invalid quorum hash should fail and cause no changes for sigs
68- assert not self .mninfo [1 ].node .quorum ("sign" , 104 , id , msgHash , msgHash )
69+ assert not self .mninfo [1 ].node .quorum ("sign" , q_type , id , msgHash , msgHash )
6970 assert_sigs_nochange (False , False , False , 3 )
7071 # 2. Providing a valid quorum hash should succeed and cause no changes for sigss
71- quorumHash = self .mninfo [1 ].node .quorum ("selectquorum" , 104 , id )["quorumHash" ]
72- assert self .mninfo [1 ].node .quorum ("sign" , 104 , id , msgHash , quorumHash )
72+ quorumHash = self .mninfo [1 ].node .quorum ("selectquorum" , q_type , id )["quorumHash" ]
73+ assert self .mninfo [1 ].node .quorum ("sign" , q_type , id , msgHash , quorumHash )
7374 assert_sigs_nochange (False , False , False , 3 )
7475 # Sign third share and test optional submit parameter if spork21 is enabled, should result in recovered sig
7576 # and conflict for msgHashConflict
7677 if self .options .spork21 :
7778 # 1. Providing an invalid quorum hash and set submit=false, should throw an error
78- assert_raises_rpc_error (- 8 , 'quorum not found' , self .mninfo [2 ].node .quorum , "sign" , 104 , id , msgHash , id , False )
79+ assert_raises_rpc_error (- 8 , 'quorum not found' , self .mninfo [2 ].node .quorum , "sign" , q_type , id , msgHash , id , False )
7980 # 2. Providing a valid quorum hash and set submit=false, should return a valid sigShare object
80- sig_share_rpc_1 = self .mninfo [2 ].node .quorum ("sign" , 104 , id , msgHash , quorumHash , False )
81- sig_share_rpc_2 = self .mninfo [2 ].node .quorum ("sign" , 104 , id , msgHash , "" , False )
81+ sig_share_rpc_1 = self .mninfo [2 ].node .quorum ("sign" , q_type , id , msgHash , quorumHash , False )
82+ sig_share_rpc_2 = self .mninfo [2 ].node .quorum ("sign" , q_type , id , msgHash , "" , False )
8283 assert_equal (sig_share_rpc_1 , sig_share_rpc_2 )
8384 assert_sigs_nochange (False , False , False , 3 )
8485 # 3. Sending the sig share received from RPC to the recovery member through P2P interface, should result
@@ -93,15 +94,15 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
9394 for mn in self .mninfo :
9495 assert mn .node .getconnectioncount () == self .llmq_size
9596 # Get the current recovery member of the quorum
96- q = self .nodes [0 ].quorum ('selectquorum' , 104 , id )
97+ q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
9798 mn = self .get_mninfo (q ['recoveryMembers' ][0 ])
9899 # Open a P2P connection to it
99100 p2p_interface = mn .node .add_p2p_connection (P2PInterface ())
100101 # Send the last required QSIGSHARE message to the recovery member
101102 p2p_interface .send_message (msg_qsigshare ([sig_share ]))
102103 else :
103104 # If spork21 is not enabled just sign regularly
104- self .mninfo [2 ].node .quorum ("sign" , 104 , id , msgHash )
105+ self .mninfo [2 ].node .quorum ("sign" , q_type , id , msgHash )
105106
106107 wait_for_sigs (True , False , True , 15 )
107108
@@ -110,19 +111,19 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
110111
111112 # Test `quorum verify` rpc
112113 node = self .mninfo [0 ].node
113- recsig = node .quorum ("getrecsig" , 104 , id , msgHash )
114+ recsig = node .quorum ("getrecsig" , q_type , id , msgHash )
114115 # Find quorum automatically
115116 height = node .getblockcount ()
116117 height_bad = node .getblockheader (recsig ["quorumHash" ])["height" ]
117118 hash_bad = node .getblockhash (0 )
118- assert node .quorum ("verify" , 104 , id , msgHash , recsig ["sig" ])
119- assert node .quorum ("verify" , 104 , id , msgHash , recsig ["sig" ], "" , height )
120- assert not node .quorum ("verify" , 104 , id , msgHashConflict , recsig ["sig" ])
121- assert not node .quorum ("verify" , 104 , id , msgHash , recsig ["sig" ], "" , height_bad )
119+ assert node .quorum ("verify" , q_type , id , msgHash , recsig ["sig" ])
120+ assert node .quorum ("verify" , q_type , id , msgHash , recsig ["sig" ], "" , height )
121+ assert not node .quorum ("verify" , q_type , id , msgHashConflict , recsig ["sig" ])
122+ assert not node .quorum ("verify" , q_type , id , msgHash , recsig ["sig" ], "" , height_bad )
122123 # Use specific quorum
123- assert node .quorum ("verify" , 104 , id , msgHash , recsig ["sig" ], recsig ["quorumHash" ])
124- assert not node .quorum ("verify" , 104 , id , msgHashConflict , recsig ["sig" ], recsig ["quorumHash" ])
125- assert_raises_rpc_error (- 8 , "quorum not found" , node .quorum , "verify" , 104 , id , msgHash , recsig ["sig" ], hash_bad )
124+ assert node .quorum ("verify" , q_type , id , msgHash , recsig ["sig" ], recsig ["quorumHash" ])
125+ assert not node .quorum ("verify" , q_type , id , msgHashConflict , recsig ["sig" ], recsig ["quorumHash" ])
126+ assert_raises_rpc_error (- 8 , "quorum not found" , node .quorum , "verify" , q_type , id , msgHash , recsig ["sig" ], hash_bad )
126127
127128 # Mine one more quorum, so that we have 2 active ones, nothing should change
128129 self .mine_quorum ()
@@ -131,23 +132,23 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
131132 # Create a recovered sig for the oldest quorum i.e. the active quorum which will be moved
132133 # out of the active set when a new quorum appears
133134 request_id = 2
134- oldest_quorum_hash = node .quorum ("list" )["llmq_test_instantsend " ][- 1 ]
135+ oldest_quorum_hash = node .quorum ("list" )["llmq_test " ][- 1 ]
135136 # Search for a request id which selects the last active quorum
136137 while True :
137- selected_hash = node .quorum ('selectquorum' , 104 , uint256_to_string (request_id ))["quorumHash" ]
138+ selected_hash = node .quorum ('selectquorum' , q_type , uint256_to_string (request_id ))["quorumHash" ]
138139 if selected_hash == oldest_quorum_hash :
139140 break
140141 else :
141142 request_id += 1
142143 # Produce the recovered signature
143144 id = uint256_to_string (request_id )
144145 for mn in self .mninfo :
145- mn .node .quorum ("sign" , 104 , id , msgHash )
146+ mn .node .quorum ("sign" , q_type , id , msgHash )
146147 # And mine a quorum to move the quorum which signed out of the active set
147148 self .mine_quorum ()
148149 # Verify the recovered sig. This triggers the "signHeight + dkgInterval" verification
149- recsig = node .quorum ("getrecsig" , 104 , id , msgHash )
150- assert node .quorum ("verify" , 104 , id , msgHash , recsig ["sig" ], "" , node .getblockcount ())
150+ recsig = node .quorum ("getrecsig" , q_type , id , msgHash )
151+ assert node .quorum ("verify" , q_type , id , msgHash , recsig ["sig" ], "" , node .getblockcount ())
151152
152153 recsig_time = self .mocktime
153154
@@ -166,21 +167,21 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
166167 wait_for_sigs (False , False , False , 15 )
167168
168169 for i in range (2 ):
169- self .mninfo [i ].node .quorum ("sign" , 104 , id , msgHashConflict )
170+ self .mninfo [i ].node .quorum ("sign" , q_type , id , msgHashConflict )
170171 for i in range (2 , 5 ):
171- self .mninfo [i ].node .quorum ("sign" , 104 , id , msgHash )
172+ self .mninfo [i ].node .quorum ("sign" , q_type , id , msgHash )
172173 wait_for_sigs (True , False , True , 15 )
173174
174175 if self .options .spork21 :
175176 id = uint256_to_string (request_id + 1 )
176177
177178 # Isolate the node that is responsible for the recovery of a signature and assert that recovery fails
178- q = self .nodes [0 ].quorum ('selectquorum' , 104 , id )
179+ q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
179180 mn = self .get_mninfo (q ['recoveryMembers' ][0 ])
180181 mn .node .setnetworkactive (False )
181182 self .wait_until (lambda : mn .node .getconnectioncount () == 0 )
182183 for i in range (4 ):
183- self .mninfo [i ].node .quorum ("sign" , 104 , id , msgHash )
184+ self .mninfo [i ].node .quorum ("sign" , q_type , id , msgHash )
184185 assert_sigs_nochange (False , False , False , 3 )
185186 # Need to re-connect so that it later gets the recovered sig
186187 mn .node .setnetworkactive (True )
0 commit comments