@@ -25,21 +25,14 @@ def set_test_params(self):
2525 self .set_dash_test_params (6 , 5 )
2626 self .set_dash_llmq_test_params (5 , 3 )
2727
28- def add_options (self , parser ):
29- parser .add_argument ("--spork21" , dest = "spork21" , default = False , action = "store_true" ,
30- help = "Test with spork21 enabled" )
31-
3228 def run_test (self ):
3329
3430 self .nodes [0 ].sporkupdate ("SPORK_17_QUORUM_DKG_ENABLED" , 0 )
35- if self .options .spork21 :
36- self .nodes [0 ].sporkupdate ("SPORK_21_QUORUM_ALL_CONNECTED" , 0 )
3731 self .wait_for_sporks_same ()
3832
3933 self .mine_quorum ()
4034
41- if self .options .spork21 :
42- assert self .mninfo [0 ].get_node (self ).getconnectioncount () == self .llmq_size
35+ assert self .mninfo [0 ].get_node (self ).getconnectioncount () == self .llmq_size
4336
4437 id = "0000000000000000000000000000000000000000000000000000000000000001"
4538 msgHash = "0000000000000000000000000000000000000000000000000000000000000002"
@@ -75,42 +68,37 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
7568 quorumHash = self .mninfo [1 ].get_node (self ).quorum ("selectquorum" , q_type , id )["quorumHash" ]
7669 assert self .mninfo [1 ].get_node (self ).quorum ("sign" , q_type , id , msgHash , quorumHash )
7770 assert_sigs_nochange (False , False , False , 3 )
78- # Sign third share and test optional submit parameter if spork21 is enabled, should result in recovered sig
71+ # Sign third share and test optional submit parameter should result in recovered sig
7972 # and conflict for msgHashConflict
80- if self .options .spork21 :
81- # 1. Providing an invalid quorum hash and set submit=false, should throw an error
82- assert_raises_rpc_error (- 8 , 'quorum not found' , self .mninfo [2 ].get_node (self ).quorum , "sign" , q_type , id , msgHash , id , False )
83- # 2. Providing a valid quorum hash and set submit=false, should return a valid sigShare object
84- sig_share_rpc_1 = self .mninfo [2 ].get_node (self ).quorum ("sign" , q_type , id , msgHash , quorumHash , False )
85- sig_share_rpc_2 = self .mninfo [2 ].get_node (self ).quorum ("sign" , q_type , id , msgHash , "" , False )
86- assert_equal (sig_share_rpc_1 , sig_share_rpc_2 )
87- assert_sigs_nochange (False , False , False , 3 )
88- # 3. Sending the sig share received from RPC to the recovery member through P2P interface, should result
89- # in a recovered sig
90- sig_share = CSigShare ()
91- sig_share .llmqType = int (sig_share_rpc_1 ["llmqType" ])
92- sig_share .quorumHash = int (sig_share_rpc_1 ["quorumHash" ], 16 )
93- sig_share .quorumMember = int (sig_share_rpc_1 ["quorumMember" ])
94- sig_share .id = int (sig_share_rpc_1 ["id" ], 16 )
95- sig_share .msgHash = int (sig_share_rpc_1 ["msgHash" ], 16 )
96- sig_share .sigShare = bytes .fromhex (sig_share_rpc_1 ["signature" ])
97- for mn in self .mninfo : # type: MasternodeInfo
98- assert mn .get_node (self ).getconnectioncount () == self .llmq_size
99- # Get the current recovery member of the quorum
100- q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
101- mn : MasternodeInfo = self .get_mninfo (q ['recoveryMembers' ][0 ])
102- # Open a P2P connection to it
103- p2p_interface = mn .get_node (self ).add_p2p_connection (P2PInterface ())
104- # Send the last required QSIGSHARE message to the recovery member
105- p2p_interface .send_message (msg_qsigshare ([sig_share ]))
106- else :
107- # If spork21 is not enabled just sign regularly
108- self .mninfo [2 ].get_node (self ).quorum ("sign" , q_type , id , msgHash )
73+ # 1. Providing an invalid quorum hash and set submit=false, should throw an error
74+ assert_raises_rpc_error (- 8 , 'quorum not found' , self .mninfo [2 ].get_node (self ).quorum , "sign" , q_type , id , msgHash , id , False )
75+ # 2. Providing a valid quorum hash and set submit=false, should return a valid sigShare object
76+ sig_share_rpc_1 = self .mninfo [2 ].get_node (self ).quorum ("sign" , q_type , id , msgHash , quorumHash , False )
77+ sig_share_rpc_2 = self .mninfo [2 ].get_node (self ).quorum ("sign" , q_type , id , msgHash , "" , False )
78+ assert_equal (sig_share_rpc_1 , sig_share_rpc_2 )
79+ assert_sigs_nochange (False , False , False , 3 )
80+ # 3. Sending the sig share received from RPC to the recovery member through P2P interface, should result
81+ # in a recovered sig
82+ sig_share = CSigShare ()
83+ sig_share .llmqType = int (sig_share_rpc_1 ["llmqType" ])
84+ sig_share .quorumHash = int (sig_share_rpc_1 ["quorumHash" ], 16 )
85+ sig_share .quorumMember = int (sig_share_rpc_1 ["quorumMember" ])
86+ sig_share .id = int (sig_share_rpc_1 ["id" ], 16 )
87+ sig_share .msgHash = int (sig_share_rpc_1 ["msgHash" ], 16 )
88+ sig_share .sigShare = bytes .fromhex (sig_share_rpc_1 ["signature" ])
89+ for mn in self .mninfo : # type: MasternodeInfo
90+ assert mn .get_node (self ).getconnectioncount () == self .llmq_size
91+ # Get the current recovery member of the quorum
92+ q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
93+ mn : MasternodeInfo = self .get_mninfo (q ['recoveryMembers' ][0 ])
94+ # Open a P2P connection to it
95+ p2p_interface = mn .get_node (self ).add_p2p_connection (P2PInterface ())
96+ # Send the last required QSIGSHARE message to the recovery member
97+ p2p_interface .send_message (msg_qsigshare ([sig_share ]))
10998
11099 wait_for_sigs (True , False , True , 15 )
111100
112- if self .options .spork21 :
113- mn .get_node (self ).disconnect_p2ps ()
101+ mn .get_node (self ).disconnect_p2ps ()
114102
115103 # Test `quorum verify` rpc
116104 node = self .mninfo [0 ].get_node (self )
@@ -175,29 +163,28 @@ def assert_sigs_nochange(hasrecsigs, isconflicting1, isconflicting2, timeout):
175163 self .mninfo [i ].get_node (self ).quorum ("sign" , q_type , id , msgHash )
176164 wait_for_sigs (True , False , True , 15 )
177165
178- if self .options .spork21 :
179- id = uint256_to_string (request_id + 1 )
180-
181- # Isolate the node that is responsible for the recovery of a signature and assert that recovery fails
182- q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
183- mn : MasternodeInfo = self .get_mninfo (q ['recoveryMembers' ][0 ])
184- mn .get_node (self ).setnetworkactive (False )
185- self .wait_until (lambda : mn .get_node (self ).getconnectioncount () == 0 )
186- for i in range (4 ):
187- self .mninfo [i ].get_node (self ).quorum ("sign" , q_type , id , msgHash )
188- assert_sigs_nochange (False , False , False , 3 )
189- # Need to re-connect so that it later gets the recovered sig
190- mn .get_node (self ).setnetworkactive (True )
191- self .connect_nodes (mn .nodeIdx , 0 )
192- force_finish_mnsync (mn .get_node (self ))
193- # Make sure intra-quorum connections were also restored
194- self .bump_mocktime (1 ) # need this to bypass quorum connection retry timeout
195- self .wait_until (lambda : mn .get_node (self ).getconnectioncount () == self .llmq_size , timeout = 10 )
196- mn .get_node (self ).ping ()
197- self .wait_until (lambda : all ('pingwait' not in peer for peer in mn .get_node (self ).getpeerinfo ()))
198- # Let 2 seconds pass so that the next node is used for recovery, which should succeed
199- self .bump_mocktime (2 )
200- wait_for_sigs (True , False , True , 2 )
166+ id = uint256_to_string (request_id + 1 )
167+
168+ # Isolate the node that is responsible for the recovery of a signature and assert that recovery fails
169+ q = self .nodes [0 ].quorum ('selectquorum' , q_type , id )
170+ mn : MasternodeInfo = self .get_mninfo (q ['recoveryMembers' ][0 ])
171+ mn .get_node (self ).setnetworkactive (False )
172+ self .wait_until (lambda : mn .get_node (self ).getconnectioncount () == 0 )
173+ for i in range (4 ):
174+ self .mninfo [i ].get_node (self ).quorum ("sign" , q_type , id , msgHash )
175+ assert_sigs_nochange (False , False , False , 3 )
176+ # Need to re-connect so that it later gets the recovered sig
177+ mn .get_node (self ).setnetworkactive (True )
178+ self .connect_nodes (mn .nodeIdx , 0 )
179+ force_finish_mnsync (mn .get_node (self ))
180+ # Make sure intra-quorum connections were also restored
181+ self .bump_mocktime (1 ) # need this to bypass quorum connection retry timeout
182+ self .wait_until (lambda : mn .get_node (self ).getconnectioncount () == self .llmq_size , timeout = 10 )
183+ mn .get_node (self ).ping ()
184+ self .wait_until (lambda : all ('pingwait' not in peer for peer in mn .get_node (self ).getpeerinfo ()))
185+ # Let 2 seconds pass so that the next node is used for recovery, which should succeed
186+ self .bump_mocktime (2 )
187+ wait_for_sigs (True , False , True , 2 )
201188
202189if __name__ == '__main__' :
203190 LLMQSigningTest ().main ()
0 commit comments