1919 p2p_port ,
2020 bytes_to_hex_str ,
2121 set_node_times ,
22- sync_blocks ,
23- sync_mempools ,
2422)
2523
2624from decimal import Decimal
@@ -102,7 +100,7 @@ def run_test(self):
102100 for peer in [0 , 2 ]:
103101 for j in range (25 ):
104102 self .mocktime = self .generate_pow (peer , self .mocktime )
105- sync_blocks ( self .nodes )
103+ self .sync_blocks ( )
106104
107105 # 2) node[1] sends his entire balance (50 mature rewards) to node[2]
108106 # - node[2] stakes a block - node[1] locks the change
@@ -112,9 +110,9 @@ def run_test(self):
112110 assert_equal (self .nodes [1 ].getbalance (), 50 * 250 )
113111 txid = self .nodes [1 ].sendtoaddress (self .nodes [2 ].getnewaddress (), (50 * 250 - 0.01 ))
114112 assert (txid is not None )
115- sync_mempools ( self .nodes )
113+ self .sync_mempools ( )
116114 self .mocktime = self .generate_pos (2 , self .mocktime )
117- sync_blocks ( self .nodes )
115+ self .sync_blocks ( )
118116 # lock the change output (so it's not used as stake input in generate_pos)
119117 for x in self .nodes [1 ].listunspent ():
120118 assert (self .nodes [1 ].lockunspent (False , [{"txid" : x ['txid' ], "vout" : x ['vout' ]}]))
@@ -128,7 +126,7 @@ def run_test(self):
128126 self .sync_all ()
129127 for i in range (6 ):
130128 self .mocktime = self .generate_pow (0 , self .mocktime )
131- sync_blocks ( self .nodes )
129+ self .sync_blocks ( )
132130 assert_equal (self .nodes [0 ].getshieldbalance (), 250 )
133131
134132 # 3) nodes[0] generates a owner address
@@ -193,9 +191,9 @@ def run_test(self):
193191 assert_equal (res ["staker_address" ], staker_address )
194192 fee = self .nodes [0 ].viewshieldtransaction (res ["txid" ])['fee' ]
195193 # sync and mine 2 blocks
196- sync_mempools ( self .nodes )
194+ self .sync_mempools ( )
197195 self .mocktime = self .generate_pos (2 , self .mocktime )
198- sync_blocks ( self .nodes )
196+ self .sync_blocks ( )
199197 self .log .info ("%d Txes created." % NUM_OF_INPUTS )
200198 # check balances:
201199 self .expected_balance = NUM_OF_INPUTS * INPUT_VALUE
@@ -215,9 +213,9 @@ def run_test(self):
215213 txhash = self .spendUTXOwithNode (u , 0 )
216214 assert (txhash != None )
217215 self .log .info ("Good. Owner was able to spend - tx: %s" % str (txhash ))
218- sync_mempools ( self .nodes )
216+ self .sync_mempools ( )
219217 self .mocktime = self .generate_pos (2 , self .mocktime )
220- sync_blocks ( self .nodes )
218+ self .sync_blocks ( )
221219 # check tx
222220 self .check_tx_in_chain (0 , txhash )
223221 self .check_tx_in_chain (1 , txhash )
@@ -251,7 +249,7 @@ def run_test(self):
251249 self .spendUTXOwithNode , u , 1 )
252250 self .log .info ("Good. Cold staker was NOT able to spend (failed OP_CHECKCOLDSTAKEVERIFY)" )
253251 self .mocktime = self .generate_pos (2 , self .mocktime )
254- sync_blocks ( self .nodes )
252+ self .sync_blocks ( )
255253
256254 # 9) check that the staker can use the coins to stake a block with internal miner.
257255 # --------------------------------------------------------------------------------
@@ -264,7 +262,7 @@ def run_test(self):
264262 self .log .info ("Block %s submitted" % newblockhash )
265263
266264 # Verify that nodes[0] accepts it
267- sync_blocks ( self .nodes )
265+ self .sync_blocks ( )
268266 assert_equal (self .nodes [0 ].getblockcount (), self .nodes [1 ].getblockcount ())
269267 assert_equal (newblockhash , self .nodes [0 ].getbestblockhash ())
270268 self .log .info ("Great. Cold-staked block was accepted!" )
@@ -292,7 +290,7 @@ def run_test(self):
292290 assert_equal (new_block .hash , self .nodes [1 ].getbestblockhash ())
293291
294292 # Verify that nodes[0] accepts it
295- sync_blocks ( self .nodes )
293+ self .sync_blocks ( )
296294 assert_equal (self .nodes [0 ].getblockcount (), self .nodes [1 ].getblockcount ())
297295 assert_equal (new_block .hash , self .nodes [0 ].getbestblockhash ())
298296 self .log .info ("Great. Cold-staked block was accepted!" )
@@ -321,7 +319,7 @@ def run_test(self):
321319 assert ("rejected" in ret )
322320
323321 # Verify that nodes[0] rejects it
324- sync_blocks ( self .nodes )
322+ self .sync_blocks ( )
325323 assert_raises_rpc_error (- 5 , "Block not found" , self .nodes [0 ].getblock , new_block .hash )
326324 self .log .info ("Great. Malicious cold-staked block was NOT accepted!" )
327325 self .checkBalances ()
@@ -345,7 +343,7 @@ def run_test(self):
345343 assert_equal (ret , "bad-p2cs-outs" )
346344
347345 # Verify that nodes[0] rejects it
348- sync_blocks ( self .nodes )
346+ self .sync_blocks ( )
349347 assert_raises_rpc_error (- 5 , "Block not found" , self .nodes [0 ].getblock , new_block .hash )
350348 self .log .info ("Great. Malicious cold-staked block was NOT accepted!" )
351349 self .checkBalances ()
@@ -355,7 +353,7 @@ def run_test(self):
355353 # ----------------------------------------------------------------------------------------
356354 self .log .info ("Let's void the contracts." )
357355 self .mocktime = self .generate_pos (2 , self .mocktime )
358- sync_blocks ( self .nodes )
356+ self .sync_blocks ( )
359357 print ("*** 13 ***" )
360358 self .log .info ("Cancel the stake delegation spending the delegated utxos..." )
361359 delegated_utxos = getDelegatedUtxos (self .nodes [0 ].listunspent ())
@@ -364,19 +362,19 @@ def run_test(self):
364362 txhash = self .spendUTXOsWithNode (delegated_utxos , 0 )
365363 assert (txhash != None )
366364 self .log .info ("Good. Owner was able to void the stake delegations - tx: %s" % str (txhash ))
367- sync_mempools ( self .nodes )
365+ self .sync_blocks ( )
368366 self .mocktime = self .generate_pos (2 , self .mocktime )
369- sync_blocks ( self .nodes )
367+ self .sync_blocks ( )
370368
371369 # deactivate SPORK 17 and check that the owner can still spend the last utxo
372370 self .setColdStakingEnforcement (False )
373371 assert (not self .isColdStakingEnforced ())
374372 txhash = self .spendUTXOsWithNode ([final_spend ], 0 )
375373 assert (txhash != None )
376374 self .log .info ("Good. Owner was able to void a stake delegation (with SPORK 17 disabled) - tx: %s" % str (txhash ))
377- sync_mempools ( self .nodes )
375+ self .sync_mempools ( )
378376 self .mocktime = self .generate_pos (2 , self .mocktime )
379- sync_blocks ( self .nodes )
377+ self .sync_blocks ( )
380378 # check tx
381379 self .check_tx_in_chain (0 , txhash )
382380 self .check_tx_in_chain (1 , txhash )
@@ -403,17 +401,17 @@ def run_test(self):
403401 for peer in [0 , 2 ]:
404402 for j in range (25 ):
405403 self .mocktime = self .generate_pos (peer , self .mocktime )
406- sync_blocks ( self .nodes )
404+ self .sync_blocks ( )
407405 self .expected_balance = self .expected_immature_balance
408406 self .expected_immature_balance = 0
409407 self .checkBalances ()
410408 delegated_utxos = getDelegatedUtxos (self .nodes [0 ].listunspent ())
411409 txhash = self .spendUTXOsWithNode (delegated_utxos , 0 )
412410 assert (txhash != None )
413411 self .log .info ("Good. Owner was able to spend the cold staked coins - tx: %s" % str (txhash ))
414- sync_mempools ( self .nodes )
412+ self .sync_mempools ( )
415413 self .mocktime = self .generate_pos (2 , self .mocktime )
416- sync_blocks ( self .nodes )
414+ self .sync_blocks ( )
417415 # check tx
418416 self .check_tx_in_chain (0 , txhash )
419417 self .check_tx_in_chain (1 , txhash )
@@ -481,8 +479,5 @@ def add_output_to_coinstake(self, block, value, peer=1):
481479 block .re_sign_block ()
482480
483481
484-
485-
486-
487482if __name__ == '__main__' :
488483 PIVX_ColdStakingTest ().main ()
0 commit comments