Skip to content

Commit

Permalink
[Tests] rename base class to PivxTestFramework
Browse files Browse the repository at this point in the history
Github-Pull: #1218
Rebased-From: 8f668b6
  • Loading branch information
random-zebra authored and Fuzzbawls committed Jan 11, 2020
1 parent ab553bf commit baa97af
Show file tree
Hide file tree
Showing 75 changed files with 167 additions and 164 deletions.
2 changes: 1 addition & 1 deletion test/functional/README.md
Expand Up @@ -29,7 +29,7 @@ don't have test cases for.
- Avoid wildcard imports
- Use a module-level docstring to describe what the test is testing, and how it
is testing it.
- When subclassing the BitcoinTestFramwork, place overrides for the
- When subclassing the PivxTestFramwork, place overrides for the
`set_test_params()`, `add_options()` and `setup_xxxx()` methods at the top of
the subclass, then locally-defined helper methods, then the `run_test()` method.
- Use `'{}'.format(x)` for string formatting, not `'%s' % x`.
Expand Down
4 changes: 2 additions & 2 deletions test/functional/create_cache.py
Expand Up @@ -9,9 +9,9 @@
tests are being run in parallel.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework

class CreateCache(BitcoinTestFramework):
class CreateCache(PivxTestFramework):
# Test network and test nodes are not required:

def set_test_params(self):
Expand Down
10 changes: 5 additions & 5 deletions test/functional/example_test.py
Expand Up @@ -24,7 +24,7 @@
network_thread_join,
network_thread_start,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
Expand Down Expand Up @@ -66,11 +66,11 @@ def custom_function():
If this function is more generally useful for other tests, consider
moving it to a module in test_framework."""
# self.log.info("running custom_function") # Oops! Can't run self.log outside the BitcoinTestFramework
# self.log.info("running custom_function") # Oops! Can't run self.log outside the PivxTestFramework
pass

class ExampleTest(BitcoinTestFramework):
# Each functional test is a subclass of the BitcoinTestFramework class.
class ExampleTest(PivxTestFramework):
# Each functional test is a subclass of the PivxTestFramework class.

# Override the set_test_params(), add_options(), setup_chain(), setup_network()
# and setup_nodes() methods to customize the test setup as required.
Expand Down Expand Up @@ -125,7 +125,7 @@ def custom_method(self):
Define it in a method here because you're going to use it repeatedly.
If you think it's useful in general, consider moving it to the base
BitcoinTestFramework class so other tests can use it."""
PivxTestFramework class so other tests can use it."""

self.log.info("Running custom_method")

Expand Down
4 changes: 2 additions & 2 deletions test/functional/fake_stake/base_test.py
Expand Up @@ -14,7 +14,7 @@
from test_framework.key import CECKey
from test_framework.messages import CTransaction, CTxOut, CTxIn, COIN, msg_block
from test_framework.mininode import network_thread_start
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
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

Expand All @@ -24,7 +24,7 @@
General Test Class to be extended by individual tests for each attack test
'''
class PIVX_FakeStakeTest(BitcoinTestFramework):
class PIVX_FakeStakeTest(PivxTestFramework):

def set_test_params(self):
''' Setup test environment
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_block.py
Expand Up @@ -399,7 +399,7 @@ def update_block(block_number, new_transactions):
b26 = update_block(26, [])
yield rejected(RejectResult(16, b'bad-cb-length'))

# Extend the b26 chain to make sure bitcoind isn't accepting b26
# Extend the b26 chain to make sure pivxd isn't accepting b26
block(27, spend=out[7])
yield rejected(False)

Expand All @@ -411,7 +411,7 @@ def update_block(block_number, new_transactions):
b28 = update_block(28, [])
yield rejected(RejectResult(16, b'bad-cb-length'))

# Extend the b28 chain to make sure bitcoind isn't accepting b28
# Extend the b28 chain to make sure pivxd isn't accepting b28
block(29, spend=out[7])
yield rejected(False)

Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_cltv.py
Expand Up @@ -8,7 +8,7 @@
1351.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *
from test_framework.mininode import *
from test_framework.blocktools import create_coinbase, create_block
Expand Down Expand Up @@ -59,7 +59,7 @@ def create_transaction(node, coinbase, to_address, amount):
tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex'])))
return tx

class BIP65Test(BitcoinTestFramework):
class BIP65Test(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']]
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_coldStaking.py
Expand Up @@ -16,7 +16,7 @@
from test_framework.mininode import network_thread_start
from test_framework.pivx_node import PivxTestNode
from test_framework.script import CScript, OP_CHECKSIG
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import hash256, connect_nodes_bi, p2p_port, bytes_to_hex_str, \
hex_str_to_bytes, assert_equal, assert_greater_than, sync_chain, assert_raises_rpc_error

Expand All @@ -25,7 +25,7 @@ def getDelegatedUtxos(utxos):
return [x for x in utxos if x["scriptPubKey"][:10] == '76a97b63d1']


class PIVX_ColdStakingTest(BitcoinTestFramework):
class PIVX_ColdStakingTest(PivxTestFramework):

def set_test_params(self):
self.setup_clean_chain = True
Expand Down
6 changes: 3 additions & 3 deletions test/functional/feature_config_args.py
Expand Up @@ -6,10 +6,10 @@

import os

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import get_datadir_path

class ConfArgsTest(BitcoinTestFramework):
class ConfArgsTest(PivxTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand All @@ -28,7 +28,7 @@ def run_test(self):
self.assert_start_raises_init_error(0, ['-datadir='+new_data_dir], 'Error: Specified data directory "' + new_data_dir + '" does not exist.')

# Check that using non-existent datadir in conf file fails
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
conf_file = os.path.join(default_data_dir, "pivx.conf")
with open(conf_file, 'a', encoding='utf8') as f:
f.write("datadir=" + new_data_dir + "\n")
self.assert_start_raises_init_error(0, ['-conf='+conf_file], 'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.')
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_fee_estimation.py
Expand Up @@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test fee estimation code."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *
from test_framework.script import CScript, OP_1, OP_DROP, OP_2, OP_HASH160, OP_EQUAL, hash160, OP_TRUE
from test_framework.mininode import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
Expand Down Expand Up @@ -140,7 +140,7 @@ def check_estimates(node, fees_seen, max_invalid, print_estimates = True):
return all_estimates


class EstimateFeeTest(BitcoinTestFramework):
class EstimateFeeTest(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 3

Expand Down
10 changes: 5 additions & 5 deletions test/functional/feature_help.py
Expand Up @@ -2,13 +2,13 @@
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Verify that starting bitcoin with -h works as expected."""
"""Verify that starting pivx with -h works as expected."""
import subprocess

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import assert_equal

class HelpTest(BitcoinTestFramework):
class HelpTest(PivxTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand All @@ -18,7 +18,7 @@ def setup_network(self):
# Don't start the node

def run_test(self):
self.log.info("Start bitcoin with -h for help text")
self.log.info("Start pivx with -h for help text")
self.nodes[0].start(extra_args=['-?'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
# Node should exit immediately and output help to stdout.
ret_code = self.nodes[0].process.wait(timeout=1)
Expand All @@ -28,7 +28,7 @@ def run_test(self):
self.log.info("Help text received: {} (...)".format(output[0:60]))
self.nodes[0].running = False

self.log.info("Start bitcoin with -version for version information")
self.log.info("Start pivx with -version for version information")
self.nodes[0].start(extra_args=['-version'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
# Node should exit immediately and output version to stdout.
ret_code = self.nodes[0].process.wait(timeout=1)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_minchainwork.py
Expand Up @@ -17,13 +17,13 @@

import time

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import connect_nodes, assert_equal

# 2 hashes required per regtest block (with no difficulty adjustment)
REGTEST_WORK_PER_BLOCK = 2

class MinimumChainWorkTest(BitcoinTestFramework):
class MinimumChainWorkTest(PivxTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
Expand Down
6 changes: 3 additions & 3 deletions test/functional/feature_notifications.py
Expand Up @@ -5,10 +5,10 @@
"""Test the -alertnotify, -blocknotify and -walletnotify options."""
import os

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import assert_equal, wait_until, connect_nodes_bi

class NotificationsTest(BitcoinTestFramework):
class NotificationsTest(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True
Expand Down Expand Up @@ -66,7 +66,7 @@ def run_test(self):
self.nodes[1].generate(51)
self.sync_all()

# Give bitcoind 10 seconds to write the alert notification
# Give pivxd 10 seconds to write the alert notification
wait_until(lambda: os.path.isfile(self.alert_filename) and os.path.getsize(self.alert_filename), timeout=10)

with open(self.alert_filename, 'r', encoding='utf8') as f:
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_nulldummy.py
Expand Up @@ -13,7 +13,7 @@
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *
from test_framework.mininode import CTransaction, network_thread_start
from test_framework.blocktools import create_coinbase, create_block, add_witness_commitment
Expand All @@ -35,7 +35,7 @@ def trueDummy(tx):
tx.vin[0].scriptSig = CScript(newscript)
tx.rehash()

class NULLDUMMYTest(BitcoinTestFramework):
class NULLDUMMYTest(PivxTestFramework):

def set_test_params(self):
self.num_nodes = 1
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_proxy.py
Expand Up @@ -31,7 +31,7 @@
import os

from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import (
PORT_MIN,
PORT_RANGE,
Expand All @@ -41,7 +41,7 @@

RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports

class ProxyTest(BitcoinTestFramework):
class ProxyTest(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 4

Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_reindex.py
Expand Up @@ -9,11 +9,11 @@
- Stop the node and restart it with -reindex-chainstate. Verify that the node has reindexed up to block 3.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import wait_until
import time

class ReindexTest(BitcoinTestFramework):
class ReindexTest(PivxTestFramework):

def set_test_params(self):
self.setup_clean_chain = True
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_uacomment.py
Expand Up @@ -4,10 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the -uacomment option."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import assert_equal

class UacommentTest(BitcoinTestFramework):
class UacommentTest(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
Expand Down
4 changes: 2 additions & 2 deletions test/functional/interface_bitcoin_cli.py
Expand Up @@ -3,11 +3,11 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test pivx-cli"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import assert_equal, assert_raises_process_error, get_auth_cookie
import time

class TestBitcoinCli(BitcoinTestFramework):
class TestBitcoinCli(PivxTestFramework):

def set_test_params(self):
self.setup_clean_chain = True
Expand Down
4 changes: 2 additions & 2 deletions test/functional/interface_http.py
Expand Up @@ -4,13 +4,13 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the RPC HTTP basics."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *

import http.client
import urllib.parse

class HTTPBasicsTest (BitcoinTestFramework):
class HTTPBasicsTest (PivxTestFramework):
def set_test_params(self):
self.num_nodes = 3

Expand Down
4 changes: 2 additions & 2 deletions test/functional/interface_rest.py
Expand Up @@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the REST API."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *
from struct import *
from io import BytesIO
Expand Down Expand Up @@ -40,7 +40,7 @@ def http_post_call(host, port, path, requestdata = '', response_object = 0):

return conn.getresponse().read()

class RESTTest (BitcoinTestFramework):
class RESTTest (PivxTestFramework):
FORMAT_SEPARATOR = "."

def set_test_params(self):
Expand Down
8 changes: 4 additions & 4 deletions test/functional/interface_zmq.py
Expand Up @@ -8,7 +8,7 @@
import struct
import time

from test_framework.test_framework import BitcoinTestFramework, SkipTest
from test_framework.test_framework import PivxTestFramework, SkipTest
from test_framework.mininode import CTransaction
from test_framework.util import (assert_equal,
bytes_to_hex_str,
Expand All @@ -35,7 +35,7 @@ def receive(self):
return body


class ZMQTest (BitcoinTestFramework):
class ZMQTest (PivxTestFramework):
def set_test_params(self):
self.num_nodes = 2

Expand All @@ -46,14 +46,14 @@ def setup_nodes(self):
except ImportError:
raise SkipTest("python3-zmq module not available.")

# Check that bitcoin has been built with ZMQ enabled.
# Check that pivx has been built with ZMQ enabled.
config = configparser.ConfigParser()
if not self.options.configfile:
self.options.configfile = os.path.abspath(os.path.join(os.path.dirname(__file__), "../config.ini"))
config.read_file(open(self.options.configfile))

if not config["components"].getboolean("ENABLE_ZMQ"):
raise SkipTest("bitcoind has not been built with zmq enabled.")
raise SkipTest("pivxd has not been built with zmq enabled.")

# Initialize ZMQ context and socket.
# All messages are received in the same socket which means
Expand Down
4 changes: 2 additions & 2 deletions test/functional/mempool_limit.py
Expand Up @@ -4,10 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool limiting together/eviction with the wallet."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *

class MempoolLimitTest(BitcoinTestFramework):
class MempoolLimitTest(PivxTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand Down

0 comments on commit baa97af

Please sign in to comment.