Skip to content

Commit

Permalink
[Tests] Integrate fake stake tests into parent test suite
Browse files Browse the repository at this point in the history
This integrates each of the 5 test scripts into the parent test suite so
 they can be run from within `test_runner.py` (or still individually).
 One prominent benefit to this is that the 5 tests are now included when
 generating code coverage reports with `make cov`

`stratisx-notingatstake.py` and `pivx_fake_stake.py` are removed as the
former was a stale leftover from prior to our own test scripts, and the
latter is now redundant.
  • Loading branch information
Fuzzbawls committed Feb 27, 2019
1 parent 065f941 commit c0d8dcb
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 350 deletions.
2 changes: 1 addition & 1 deletion test/functional/fake_stake/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from test_framework.script import CScript, OP_CHECKSIG
from test_framework.util import hash256, bytes_to_hex_str, hex_str_to_bytes, connect_nodes_bi, p2p_port

from util import TestNode, create_transaction, utxo_to_stakingPrevOuts, dir_size
from .util import TestNode, create_transaction, utxo_to_stakingPrevOuts, dir_size
''' -------------------------------------------------------------------------
PIVX_FakeStakeTest CLASS ----------------------------------------------------
Expand Down
64 changes: 0 additions & 64 deletions test/functional/fake_stake/pivx_fake_stake.py

This file was deleted.

12 changes: 9 additions & 3 deletions test/functional/fake_stake/test05.py → test/functional/p2p_pos_doublespend.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 The PIVX Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

'''
Covers the scenario of a valid PoS block with a valid coinstake transaction where the
coinstake input prevout is double spent in one of the other transactions in the same block.
'''

from time import sleep

from base_test import PIVX_FakeStakeTest
from fake_stake.base_test import PIVX_FakeStakeTest


class Test_05(PIVX_FakeStakeTest):
class PoSDoubleSpend(PIVX_FakeStakeTest):

def run_test(self):
self.description = "Covers the scenario of a valid PoS block with a valid coinstake transaction where the coinstake input prevout is double spent in one of the other transactions in the same block."
Expand Down Expand Up @@ -46,3 +49,6 @@ def run_test(self):
raise AssertionError("TEST FAILED")

self.log.info("%s PASSED" % self.__class__.__name__)

if __name__ == '__main__':
PoSDoubleSpend().main()
12 changes: 9 additions & 3 deletions test/functional/fake_stake/test01.py → test/functional/p2p_pos_fakestake.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 The PIVX Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

'''
Covers the scenario of a PoS block where the coinstake input prevout is already spent.
'''

from time import sleep

from base_test import PIVX_FakeStakeTest
from fake_stake.base_test import PIVX_FakeStakeTest

class Test_01(PIVX_FakeStakeTest):
class PoSFakeStake(PIVX_FakeStakeTest):

def run_test(self):
self.description = "Covers the scenario of a PoS block where the coinstake input prevout is already spent."
Expand Down Expand Up @@ -50,3 +53,6 @@ def run_test(self):
raise AssertionError("TEST FAILED")

self.log.info("%s PASSED" % self.__class__.__name__)

if __name__ == '__main__':
PoSFakeStake().main()
12 changes: 9 additions & 3 deletions test/functional/fake_stake/test02.py → .../functional/p2p_pos_fakestake_accepted.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 The PIVX Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

'''
Covers the scenario of a valid PoS block where the coinstake input prevout is spent on main chain,
but not on the fork branch. These blocks must be accepted.
'''

from time import sleep

from base_test import PIVX_FakeStakeTest
from fake_stake.base_test import PIVX_FakeStakeTest

class Test_02(PIVX_FakeStakeTest):
class PoSFakeStakeAccepted(PIVX_FakeStakeTest):

def run_test(self):
self.description = "Covers the scenario of a valid PoS block where the coinstake input prevout is spent on main chain, but not on the fork branch. These blocks must be accepted."
Expand Down Expand Up @@ -52,3 +55,6 @@ def run_test(self):
raise AssertionError("TEST FAILED")

self.log.info("%s PASSED" % self.__class__.__name__)

if __name__ == '__main__':
PoSFakeStakeAccepted().main()
12 changes: 9 additions & 3 deletions test/functional/fake_stake/test03.py → test/functional/p2p_zpos_fakestake.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 The PIVX Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

'''
Covers the scenario of a zPoS block where the coinstake input is a zerocoin spend
of an already spent coin.
Expand All @@ -9,9 +12,9 @@

from test_framework.authproxy import JSONRPCException

from base_test import PIVX_FakeStakeTest
from fake_stake.base_test import PIVX_FakeStakeTest

class Test_03(PIVX_FakeStakeTest):
class zPoSFakeStake(PIVX_FakeStakeTest):

def run_test(self):
self.description = "Covers the scenario of a zPoS block where the coinstake input is a zerocoin spend of an already spent coin."
Expand Down Expand Up @@ -98,3 +101,6 @@ def run_test(self):
raise AssertionError("TEST FAILED")

self.log.info("%s PASSED" % self.__class__.__name__)

if __name__ == '__main__':
zPoSFakeStake().main()
12 changes: 9 additions & 3 deletions test/functional/fake_stake/test04.py → ...functional/p2p_zpos_fakestake_accepted.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 The PIVX Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

'''
Performs the same check as in Test_02 verifying that zPoS forked blocks that stake a zerocoin which is spent on mainchain on an higher block are still accepted.
'''

from test_framework.authproxy import JSONRPCException
from base_test import PIVX_FakeStakeTest
from fake_stake.base_test import PIVX_FakeStakeTest
from time import sleep

class Test_04(PIVX_FakeStakeTest):
class zPoSFakeStakeAccepted(PIVX_FakeStakeTest):


def set_test_params(self):
Expand Down Expand Up @@ -109,3 +112,6 @@ def run_test(self):
raise AssertionError("TEST FAILED")

self.log.info("%s PASSED" % self.__class__.__name__)

if __name__ == '__main__':
zPoSFakeStakeAccepted().main()
Loading

0 comments on commit c0d8dcb

Please sign in to comment.