mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
(partial) Merge #18828: test: Strip down previous releases boilerplate
fa359d14c09c6b139dead5da17c5a1c02f68393c test: Strip down previous releases boilerplate (MarcoFalke) Pull request description: Reduces code bloat and mental load to write compatibility tests ACKs for top commit: Sjors: tACK fa359d14c09c6b139dead5da17c5a1c02f68393c on macOS Tree-SHA512: dc66286b24b2f137e5bca99412850ec7eee8cc61cf9cdc7ab532d529220808189baea8d1b077f8b7f40d3e8881d981e1ffc5a877adb394816f1225b1186253e4
This commit is contained in:
parent
be6a045b8c
commit
ab2ff851b3
@ -9,8 +9,8 @@ import configparser
|
||||
import copy
|
||||
from _decimal import Decimal
|
||||
from enum import Enum
|
||||
import logging
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import pdb
|
||||
import random
|
||||
@ -243,10 +243,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
|
||||
self.extra_args_from_options = self.options.dashd_extra_args
|
||||
|
||||
self.options.previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
|
||||
|
||||
os.environ['PATH'] = os.pathsep.join([
|
||||
os.path.join(config['environment']['BUILDDIR'], 'src'),
|
||||
os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'),
|
||||
os.environ['PATH']
|
||||
os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'), os.environ['PATH']
|
||||
])
|
||||
|
||||
# Set up temp directory and start logging
|
||||
@ -901,6 +902,25 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if not self.is_cli_compiled():
|
||||
raise SkipTest("dash-cli has not been compiled.")
|
||||
|
||||
def skip_if_no_previous_releases(self):
|
||||
"""Skip the running test if previous releases are not available."""
|
||||
if not self.has_previous_releases():
|
||||
raise SkipTest("previous releases not available or disabled")
|
||||
|
||||
def has_previous_releases(self):
|
||||
"""Checks whether previous releases are present and enabled."""
|
||||
if os.getenv("TEST_PREVIOUS_RELEASES") == "false":
|
||||
# disabled
|
||||
return False
|
||||
|
||||
if not os.path.isdir(self.options.previous_releases_path):
|
||||
if os.getenv("TEST_PREVIOUS_RELEASES") == "true":
|
||||
raise AssertionError("TEST_PREVIOUS_RELEASES=true but releases missing: {}".format(
|
||||
self.options.previous_releases_path))
|
||||
# missing
|
||||
return False
|
||||
return True
|
||||
|
||||
def is_cli_compiled(self):
|
||||
"""Checks whether dash-cli was compiled."""
|
||||
return self.config["components"].getboolean("ENABLE_CLI")
|
||||
|
@ -12,14 +12,15 @@ contrib/devtools/previous_release.sh -b v0.15.2 v0.16.3
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework, SkipTest
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
adjust_bitcoin_conf_for_pre_17,
|
||||
assert_equal,
|
||||
assert_greater_than,
|
||||
assert_is_hex_string
|
||||
assert_is_hex_string,
|
||||
)
|
||||
|
||||
|
||||
class UpgradeWalletTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
@ -33,32 +34,16 @@ class UpgradeWalletTest(BitcoinTestFramework):
|
||||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
self.skip_if_no_bdb()
|
||||
self.skip_if_no_previous_releases()
|
||||
|
||||
def setup_network(self):
|
||||
self.setup_nodes()
|
||||
|
||||
def setup_nodes(self):
|
||||
if os.getenv("TEST_PREVIOUS_RELEASES") == "false":
|
||||
raise SkipTest("upgradewallet RPC tests")
|
||||
|
||||
releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
|
||||
if not os.path.isdir(releases_path):
|
||||
if os.getenv("TEST_PREVIOUS_RELEASES") == "true":
|
||||
raise AssertionError("TEST_PREVIOUS_RELEASES=1 but releases missing: " + releases_path)
|
||||
raise SkipTest("This test requires binaries for previous releases")
|
||||
|
||||
self.add_nodes(self.num_nodes, extra_args=self.extra_args, versions=[
|
||||
None,
|
||||
160300,
|
||||
150200
|
||||
], binary=[
|
||||
self.options.bitcoind,
|
||||
releases_path + "/v0.16.3/bin/bitcoind",
|
||||
releases_path + "/v0.15.2/bin/bitcoind",
|
||||
], binary_cli=[
|
||||
self.options.bitcoincli,
|
||||
releases_path + "/v0.16.3/bin/bitcoin-cli",
|
||||
releases_path + "/v0.15.2/bin/bitcoin-cli",
|
||||
150200,
|
||||
])
|
||||
# adapt bitcoin.conf, because older bitcoind's don't recognize config sections
|
||||
adjust_bitcoin_conf_for_pre_17(self.nodes[1].bitcoinconf)
|
||||
|
Loading…
Reference in New Issue
Block a user