Skip to content

Commit c6c81a7

Browse files
committed
[Tests] fake_stake: test03 updated
1 parent 0d8cf55 commit c6c81a7

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

test/functional/fake_stake/base_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def test_spam(self, name, stakingPrevOuts,
341341
time.sleep(1)
342342

343343
try:
344+
self.test_nodes[0].handle_connect()
344345
self.test_nodes[0].send_message(msg)
345346
time.sleep(2)
346347
block_ret = self.node.getblock(block.hash)
@@ -366,6 +367,11 @@ def test_spam(self, name, stakingPrevOuts,
366367
self.log.warning(exc_msg)
367368
err_msgs.append(exc_msg)
368369

370+
except Exception as e:
371+
exc_msg = str(e)
372+
self.log.error(exc_msg)
373+
err_msgs.append(exc_msg)
374+
369375
# remove a random prevout from the list
370376
# (to randomize block creation if the same height is picked two times)
371377
del stakingPrevOuts[choice(list(stakingPrevOuts))]

test/functional/fake_stake/test03.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@
1111
from test_framework.authproxy import JSONRPCException
1212

1313
from base_test import PIVX_FakeStakeTest
14-
from util import mints_to_stakingPrevOuts
1514

1615
class Test_03(PIVX_FakeStakeTest):
1716

1817
def run_test(self):
1918
self.description = "Covers the scenario of a zPoS block where the coinstake input is a zerocoin spend of an already spent coin."
2019
self.init_test()
2120

22-
DENOM_TO_USE = 5000 # zc denomination
23-
INITAL_MINED_BLOCKS = 321
24-
MORE_MINED_BLOCKS = 301
25-
self.NUM_BLOCKS = 2
21+
DENOM_TO_USE = 5000 # zc denomination
22+
INITAL_MINED_BLOCKS = 321 # First mined blocks (rewards collected to mint)
23+
MORE_MINED_BLOCKS = 301 # More blocks mined before spending zerocoins
24+
self.NUM_BLOCKS = 2 # Number of spammed blocks
2625

2726
# 1) Starting mining blocks
2827
self.log.info("Mining %d blocks to get to zPOS activation...." % INITAL_MINED_BLOCKS)
@@ -58,7 +57,7 @@ def run_test(self):
5857
sleep(2)
5958
mints = self.node.listmintedzerocoins(True, True)
6059
sleep(1)
61-
stakingPrevOuts = mints_to_stakingPrevOuts(mints)
60+
stakingPrevOuts = self.get_prevouts(mints, zpos=True)
6261
mints_hashes = [x["serial hash"] for x in mints]
6362

6463
# This mints are not ready spendable, only few of them.
@@ -96,4 +95,10 @@ def run_test(self):
9695

9796
# 7) Create "Fake Stake" blocks and send them
9897
self.log.info("Creating Fake stake zPoS blocks...")
99-
self.test_spam("Main", stakingPrevOuts, spendingPrevOuts=spendingPrevOuts, fZPoS=True)
98+
err_msgs = self.test_spam("Main", stakingPrevOuts, spendingPrevOuts=spendingPrevOuts, fZPoS=True)
99+
100+
if not len(err_msgs) == 0:
101+
self.log.error("result: " + " | ".join(err_msgs))
102+
raise AssertionError("TEST FAILED")
103+
104+
self.log.info("%s PASSED" % self.__class__.__name__)

0 commit comments

Comments
 (0)