mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Chore: Remove docker support (#2054)
* Chore: Remove docker support * use pip instead of pip3 * kick * kick Co-authored-by: Manolis Mandrapilias <70536101+moneymanolis@users.noreply.github.com>
This commit is contained in:
parent
e019658b8c
commit
db8e413891
15 changed files with 98 additions and 437 deletions
|
|
@ -59,9 +59,7 @@ check:
|
|||
- pip3 install -e .
|
||||
- pip3 install -r test_requirements.txt
|
||||
- python3 setup.py install # compiles babel stuff as well (might make pip install obsolete)
|
||||
# pytest --docker not working? Uncomment this for better debugging:
|
||||
# - python3 tests/conftest.py
|
||||
- py.test --cov-report term --cov cryptoadvance --docker
|
||||
- py.test --cov-report term --cov cryptoadvance
|
||||
|
||||
.test-cypress:
|
||||
image: registry.gitlab.com/cryptoadvance/specter-desktop/cypress-python-jammy:v9.7.0
|
||||
|
|
@ -122,12 +120,24 @@ release_binary_windows:
|
|||
tags:
|
||||
- windows
|
||||
before_script:
|
||||
- whoami
|
||||
- python -V
|
||||
- pip3 install virtualenv
|
||||
- pip3 --version
|
||||
- pip install virtualenv
|
||||
- virtualenv --python=python3 .env
|
||||
- .\.env\Scripts\activate
|
||||
- pip3 install -r test_requirements.txt
|
||||
- whoami
|
||||
- pip install -r test_requirements.txt || echo "why the heck does this fail with:"
|
||||
# Collecting distlib<1,>=0.3.6
|
||||
# Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
|
||||
# ------------------------------------- 468.5/468.5 kB 30.6 MB/s eta 0:00:00
|
||||
# ERROR: To modify pip, please run the following command:
|
||||
# C:\gitlab-runner\builds\xPkLDUk2\0\k9ert\specter-desktop\.env\Scripts\python.exe -m pip install -r test_requirements.txt
|
||||
# Uploading artifacts for failed job
|
||||
|
||||
# That error message above doesn't even help a bit
|
||||
# However it seems that if you do that yet another time, it doesn't fail!
|
||||
- pip install -r test_requirements.txt -vv
|
||||
|
||||
script:
|
||||
# This script won't execute if the script before that fails
|
||||
# No need to check the version-scheme again
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-b
|
|||
|
||||
Due to that setup there are some specifics which are mainly addressed in tests/conftest
|
||||
start_bitcoind-function:
|
||||
* some pytest specific stuff to enable "pytest --docker" (used in .gitlab-ci.yml)
|
||||
* adding -rpcallowip= (from a docker network) to bitcoind
|
||||
* not use localhost but the docker-network-ip-address when talking to the bitcoind
|
||||
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ docker pull registry.gitlab.com/cryptoadvance/specter-desktop/python-bitcoind:v0
|
|||
# install prerequisites
|
||||
pip3 install docker
|
||||
|
||||
# Run all the tests against the docker bitcoind image
|
||||
pytest -m "no elm" --docker
|
||||
# Run all the tests but not elm ones
|
||||
pytest -m "no elm"
|
||||
```
|
||||
|
||||
Running specific test subsets:
|
||||
|
|
@ -374,11 +374,9 @@ In order to enable that, you need to activate pytest support by placing a settin
|
|||
"python.pythonPath": ".env/bin/python3.7",
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.nosetestsEnabled": false,
|
||||
"python.testing.pytestEnabled": true,
|
||||
"python.testing.pytestArgs": ["--docker"]
|
||||
"python.testing.pytestEnabled": true
|
||||
}
|
||||
```
|
||||
**WARNING**: Make sure to never stop a unittest in between. Simply continue with the test and let it run through. Otherwise the docker-container used for the test won't get cleaned up and your subsequent test-runs will fail with strange issues. If you did that, simply kill the container (```docker ps; docker kill ...```)
|
||||
|
||||
More information on python-unit-tests on VS-Code can be found at the [VS-python-documentation](https://code.visualstudio.com/docs/python/testing).
|
||||
|
||||
|
|
@ -428,7 +426,7 @@ PyCharm already comes with integrated support for pyTest.
|
|||
|
||||
To run/debug all tests:
|
||||
* Right click on the `<PROJECT_ROOT>/test` folder and execute `Run pytest in tests`
|
||||
* Edit the automatically generated run configuration and optionally add the `--docker` argument, change the working directory to your `<PROJECT_ROOT>` directory
|
||||
* Edit the automatically generated run configuration, change the working directory to your `<PROJECT_ROOT>` directory
|
||||
* Apply, Save & Run again
|
||||
|
||||
To run/debug an individual test, open the script and run/debug by clicking the play icon on the left side of the method declaration.
|
||||
|
|
|
|||
|
|
@ -32,15 +32,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
@click.command()
|
||||
@click.option("--quiet/--no-quiet", default=False, help="Output as little as possible.")
|
||||
@click.option(
|
||||
"--nodocker",
|
||||
default=False,
|
||||
is_flag=True,
|
||||
help="Use without docker. (By default docker is used.)",
|
||||
)
|
||||
@click.option(
|
||||
"--docker-tag", "docker_tag", default="latest", help="Use a specific docker-tag"
|
||||
)
|
||||
@click.option(
|
||||
"--data-dir",
|
||||
help="Specify a (maybe not yet existing) datadir. Works only with --nodocker. (Default is /tmp/bitcoind_plain_datadir)",
|
||||
|
|
@ -90,8 +81,6 @@ logger = logging.getLogger(__name__)
|
|||
)
|
||||
def bitcoind(
|
||||
quiet,
|
||||
nodocker,
|
||||
docker_tag,
|
||||
data_dir,
|
||||
port,
|
||||
log_stdout,
|
||||
|
|
@ -109,8 +98,6 @@ def bitcoind(
|
|||
noded(
|
||||
"bitcoin",
|
||||
quiet,
|
||||
nodocker,
|
||||
docker_tag,
|
||||
data_dir,
|
||||
port,
|
||||
log_stdout,
|
||||
|
|
@ -194,8 +181,6 @@ def elementsd(
|
|||
noded(
|
||||
"elements",
|
||||
quiet,
|
||||
True, # nodocker
|
||||
None, # docker_tag
|
||||
data_dir,
|
||||
port,
|
||||
log_stdout,
|
||||
|
|
@ -211,8 +196,6 @@ def elementsd(
|
|||
def noded(
|
||||
node_impl,
|
||||
quiet,
|
||||
nodocker,
|
||||
docker_tag,
|
||||
data_dir,
|
||||
port,
|
||||
log_stdout,
|
||||
|
|
@ -246,9 +229,6 @@ def noded(
|
|||
data_dir = compute_data_dir_and_set_config_obj(node_impl, data_dir, config_obj)
|
||||
|
||||
if reset:
|
||||
if not nodocker:
|
||||
echo("ERROR: --reset only works in conjunction with --nodocker currently")
|
||||
return
|
||||
did_something = kill_node_process(node_impl, echo)
|
||||
did_something = (
|
||||
purge_node_data_dir(node_impl, config_obj, echo) or did_something
|
||||
|
|
@ -257,27 +237,16 @@ def noded(
|
|||
echo("Nothing to do!")
|
||||
return
|
||||
mining_every_x_seconds = float(mining_period)
|
||||
if nodocker:
|
||||
echo(f"Creating plain {node_impl}d")
|
||||
if node_impl == "bitcoin":
|
||||
my_node = BitcoindPlainController(
|
||||
bitcoind_path=find_node_executable("bitcoin"), rpcport=port
|
||||
)
|
||||
elif node_impl == "elements":
|
||||
my_node = ElementsPlainController(
|
||||
elementsd_path=find_node_executable("elements"), rpcport=port
|
||||
)
|
||||
Path(data_dir).mkdir(parents=True, exist_ok=True)
|
||||
else:
|
||||
echo("Creating container")
|
||||
from ..process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
echo(f"Creating plain {node_impl}d")
|
||||
if node_impl == "bitcoin":
|
||||
my_node = BitcoindPlainController(
|
||||
bitcoind_path=find_node_executable("bitcoin"), rpcport=port
|
||||
)
|
||||
|
||||
if node_impl == "bitcoin":
|
||||
my_node = BitcoindDockerController(docker_tag=docker_tag)
|
||||
else:
|
||||
raise Exception("There is no Elementsd-Bitcoin-Controller yet!")
|
||||
elif node_impl == "elements":
|
||||
my_node = ElementsPlainController(
|
||||
elementsd_path=find_node_executable("elements"), rpcport=port
|
||||
)
|
||||
Path(data_dir).mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
echo(f"Starting {node_impl}d")
|
||||
if node_impl == "bitcoin":
|
||||
|
|
@ -294,34 +263,12 @@ def noded(
|
|||
datadir=data_dir,
|
||||
log_stdout=log_stdout,
|
||||
)
|
||||
except docker.errors.ImageNotFound:
|
||||
echo(f"Image with tag {docker_tag} does not exist!")
|
||||
echo(
|
||||
f"Try to download first with docker pull registry.gitlab.com/cryptoadvance/specter-desktop/python-bitcoind:{docker_tag}"
|
||||
)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
if str(e).startswith("There is already a node running!"):
|
||||
echo(f"{e} please reset via:")
|
||||
echo(f"python3 -m cryptoadvance.specter {node_impl}d --reset")
|
||||
else:
|
||||
raise e
|
||||
if not nodocker:
|
||||
tags_of_image = [
|
||||
image.split(":")[-1] for image in my_node.btcd_container.image.tags
|
||||
]
|
||||
if docker_tag not in tags_of_image:
|
||||
echo(
|
||||
"The running docker container is not \
|
||||
the tag you requested!"
|
||||
)
|
||||
echo(
|
||||
"please stop first with docker stop {}".format(
|
||||
my_node.btcd_container.id
|
||||
)
|
||||
)
|
||||
sys.exit(1)
|
||||
echo(f"containerImage: {my_node.btcd_container.image.tags} ")
|
||||
echo(f" url: {my_node.rpcconn.render_url()}")
|
||||
echo(f"user, password: { my_node.rpcconn.rpcuser }, secret")
|
||||
echo(f" host, port: localhost, {my_node.rpcconn.rpcport}")
|
||||
|
|
|
|||
|
|
@ -1,228 +0,0 @@
|
|||
import logging
|
||||
|
||||
# the docker-dependency is special as it's only used with pytest --docker or
|
||||
# if you manually start bitcoind --docker
|
||||
# If this fails, you need to pip install the test-requirements
|
||||
import docker
|
||||
import os
|
||||
from .node_controller import Btcd_conn, NodeController
|
||||
import signal
|
||||
import time
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BitcoindDockerController(NodeController):
|
||||
"""A class specifically controlling a docker-based bitcoind-container"""
|
||||
|
||||
def __init__(self, rpcport=18443, docker_tag="latest"):
|
||||
self.btcd_container = None
|
||||
super().__init__("bitcoin", rpcport=rpcport)
|
||||
self.docker_tag = docker_tag
|
||||
|
||||
if self.detect_bitcoind_container(rpcport) != None:
|
||||
rpcconn, btcd_container = self.detect_bitcoind_container(rpcport)
|
||||
logger.debug("Detected old container ... deleting it")
|
||||
btcd_container.stop()
|
||||
btcd_container.remove()
|
||||
|
||||
def start_bitcoind(
|
||||
self,
|
||||
cleanup_at_exit=False,
|
||||
cleanup_hard=False,
|
||||
datadir=None,
|
||||
log_stdout=False,
|
||||
extra_args=[],
|
||||
timeout=60,
|
||||
):
|
||||
self.start_node(
|
||||
cleanup_at_exit,
|
||||
cleanup_hard,
|
||||
datadir,
|
||||
log_stdout,
|
||||
extra_args,
|
||||
timeout,
|
||||
)
|
||||
|
||||
def _start_node(
|
||||
self,
|
||||
cleanup_at_exit,
|
||||
cleanup_hard=False,
|
||||
datadir=None,
|
||||
log_stdout=None,
|
||||
extra_args=[],
|
||||
):
|
||||
if datadir != None:
|
||||
# ignored
|
||||
pass
|
||||
bitcoind_path = self.construct_node_cmd(self.rpcconn, extra_args=extra_args)
|
||||
dclient = docker.from_env()
|
||||
logger.debug("Running (in docker): {}".format(bitcoind_path))
|
||||
ports = {
|
||||
"{}/tcp".format(self.rpcconn.rpcport - 1): self.rpcconn.rpcport - 1,
|
||||
"{}/tcp".format(self.rpcconn.rpcport): self.rpcconn.rpcport,
|
||||
}
|
||||
logger.debug("portmapping: {}".format(ports))
|
||||
image = dclient.images.get(
|
||||
"registry.gitlab.com/cryptoadvance/specter-desktop/python-bitcoind:{}".format(
|
||||
self.docker_tag
|
||||
)
|
||||
)
|
||||
self.btcd_container = dclient.containers.run(
|
||||
image,
|
||||
bitcoind_path,
|
||||
ports=ports,
|
||||
detach=True,
|
||||
)
|
||||
|
||||
def cleanup_docker_bitcoind(*args):
|
||||
logger.info("Cleaning up bitcoind-docker-container")
|
||||
self.btcd_container.stop()
|
||||
self.btcd_container.remove()
|
||||
|
||||
if cleanup_at_exit:
|
||||
logger.debug(
|
||||
"Register function cleanup_docker_bitcoind for SIGINT and SIGTERM"
|
||||
)
|
||||
# This is for CTRL-C --> SIGINT
|
||||
signal.signal(signal.SIGINT, cleanup_docker_bitcoind)
|
||||
# This is for kill $pid --> SIGTERM
|
||||
signal.signal(signal.SIGTERM, cleanup_docker_bitcoind)
|
||||
|
||||
logger.debug(
|
||||
"Waiting for container {} to come up".format(self.btcd_container.id)
|
||||
)
|
||||
self.wait_for_container()
|
||||
rpcconn, _ = self.detect_bitcoind_container(self.rpcconn.rpcport)
|
||||
if rpcconn == None:
|
||||
raise Exception(
|
||||
"Couldn't find container or it died already. Check the logs!"
|
||||
)
|
||||
else:
|
||||
self.rpcconn = rpcconn
|
||||
|
||||
logger.info("Started docker bitcoind")
|
||||
|
||||
return
|
||||
|
||||
def stop_bitcoind(self):
|
||||
if self.btcd_container != None:
|
||||
self.btcd_container.reload()
|
||||
if self.btcd_container.status == "running":
|
||||
_, container = self.detect_bitcoind_container(self.rpcconn.rpcport)
|
||||
if container == self.btcd_container:
|
||||
self.btcd_container.stop()
|
||||
logger.info("Stopped btcd_container {}".format(self.btcd_container))
|
||||
self.btcd_container.remove()
|
||||
return
|
||||
raise Exception("Ambigious Container running")
|
||||
|
||||
def stop_node(self):
|
||||
self.stop_bitcoind()
|
||||
|
||||
def check_existing(self):
|
||||
"""Checks whether self.btcd_container is up2date and not ambigious"""
|
||||
if self.btcd_container != None:
|
||||
self.btcd_container.reload()
|
||||
if self.btcd_container.status == "running":
|
||||
rpcconn, container = self.detect_bitcoind_container(
|
||||
self.rpcconn.rpcport
|
||||
)
|
||||
if container == self.btcd_container:
|
||||
return rpcconn
|
||||
raise Exception("Ambigious Container running")
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def search_bitcoind_container(all=False):
|
||||
"""returns a list of containers which are running bitcoind"""
|
||||
d_client = docker.from_env()
|
||||
return [
|
||||
c
|
||||
for c in d_client.containers.list(all)
|
||||
if (c.attrs["Config"].get("Cmd") or [""])[0] == "bitcoind"
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def detect_bitcoind_container(with_rpcport):
|
||||
"""checks all the containers for a bitcoind one, parses the arguments and initializes
|
||||
the object accordingly
|
||||
returns rpcconn, btcd_container
|
||||
"""
|
||||
d_client = docker.from_env()
|
||||
potential_btcd_containers = BitcoindDockerController.search_bitcoind_container()
|
||||
if len(potential_btcd_containers) == 0:
|
||||
logger.debug(
|
||||
"could not detect container. Candidates: {}".format(
|
||||
d_client.containers.list()
|
||||
)
|
||||
)
|
||||
all_candidates = BitcoindDockerController.search_bitcoind_container(
|
||||
all=True
|
||||
)
|
||||
logger.debug(
|
||||
"could not detect container. All Candidates: {}".format(all_candidates)
|
||||
)
|
||||
if len(all_candidates) > 0:
|
||||
logger.debug("100 chars of logs of first candidate")
|
||||
logger.debug(all_candidates[0].logs()[0:100])
|
||||
return None
|
||||
for btcd_container in potential_btcd_containers:
|
||||
rpcport = int(
|
||||
[
|
||||
arg
|
||||
for arg in btcd_container.attrs["Config"]["Cmd"]
|
||||
if "rpcport" in arg
|
||||
][0].split("=")[1]
|
||||
)
|
||||
if rpcport != with_rpcport:
|
||||
logger.debug(
|
||||
"checking port {} against searched port {}".format(
|
||||
type(rpcport), type(with_rpcport)
|
||||
)
|
||||
)
|
||||
continue
|
||||
rpcpassword = [
|
||||
arg
|
||||
for arg in btcd_container.attrs["Config"]["Cmd"]
|
||||
if "rpcpassword" in arg
|
||||
][0].split("=")[1]
|
||||
rpcuser = [
|
||||
arg for arg in btcd_container.attrs["Config"]["Cmd"] if "rpcuser" in arg
|
||||
][0].split("=")[1]
|
||||
if "CI" in os.environ: # this is a predefined variable in gitlab
|
||||
# This works on Linux (direct docker) and gitlab-CI but not on MAC
|
||||
ipaddress = btcd_container.attrs["NetworkSettings"]["IPAddress"]
|
||||
else:
|
||||
# This works on most machines but not on gitlab-CI
|
||||
ipaddress = "127.0.0.1"
|
||||
rpcconn = Btcd_conn(
|
||||
rpcuser=rpcuser,
|
||||
rpcpassword=rpcpassword,
|
||||
rpcport=rpcport,
|
||||
ipaddress=ipaddress,
|
||||
)
|
||||
logger.info("detected container {}".format(btcd_container.id))
|
||||
return rpcconn, btcd_container
|
||||
logger.debug("No matching container found")
|
||||
return None
|
||||
|
||||
def wait_for_container(self):
|
||||
"""waits for the docker-container to come up. Times out after 10 seconds"""
|
||||
i = 0
|
||||
while True:
|
||||
ip_address = self.btcd_container.attrs["NetworkSettings"]["IPAddress"]
|
||||
if ip_address.startswith("172"):
|
||||
self.rpcconn.ipaddress = ip_address
|
||||
break
|
||||
self.btcd_container.reload()
|
||||
time.sleep(0.5)
|
||||
i = i + 1
|
||||
if i > 20:
|
||||
raise Exception("Timeout while starting bitcoind-docker-container!")
|
||||
|
||||
def version(self):
|
||||
"""Returns the version of bitcoind, e.g. "v0.19.1" """
|
||||
version = self.get_rpc().getnetworkinfo()["subversion"]
|
||||
version = version.replace("/", "").replace("Satoshi:", "v")
|
||||
return version
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
# requirements for testing
|
||||
black==22.3.0
|
||||
pre-commit==2.13.0
|
||||
docker==4.3.1
|
||||
pip==22.0.4
|
||||
pip-tools==5.5.0
|
||||
pytest==7.1.2
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ def pytest_addoption(parser):
|
|||
see pytest_generate_tests(metafunc) on how to check that
|
||||
Also used to register the SIGUSR2 (12) as decribed in conftest.py
|
||||
"""
|
||||
parser.addoption("--docker", action="store_true", help="run bitcoind in docker")
|
||||
parser.addoption(
|
||||
"--bitcoind-version",
|
||||
action="store",
|
||||
|
|
@ -103,32 +102,23 @@ def pytest_generate_tests(metafunc):
|
|||
|
||||
|
||||
def instantiate_bitcoind_controller(
|
||||
docker, request, rpcport=18543, extra_args=[]
|
||||
request, rpcport=18543, extra_args=[]
|
||||
) -> BitcoindPlainController:
|
||||
# logging.getLogger().setLevel(logging.DEBUG)
|
||||
requested_version = request.config.getoption("--bitcoind-version")
|
||||
log_stdout = str2bool(request.config.getoption("--bitcoind-log-stdout"))
|
||||
if docker:
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
|
||||
bitcoind_controller = BitcoindDockerController(
|
||||
rpcport=rpcport, docker_tag=requested_version
|
||||
)
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller.start_bitcoind(
|
||||
cleanup_at_exit=True,
|
||||
cleanup_hard=True,
|
||||
|
|
@ -188,8 +178,8 @@ def bitcoind_path():
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bitcoin_regtest(docker, request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(docker, request, extra_args=None)
|
||||
def bitcoin_regtest(request) -> BitcoindPlainController:
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(request, extra_args=None)
|
||||
try:
|
||||
assert bitcoind_regtest.get_rpc().test_connection()
|
||||
assert not bitcoind_regtest.datadir is None
|
||||
|
|
@ -200,10 +190,10 @@ def bitcoin_regtest(docker, request):
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bitcoin_regtest2(docker, request):
|
||||
def bitcoin_regtest2(request) -> BitcoindPlainController:
|
||||
"""If a test needs two nodes ..."""
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(
|
||||
docker, request, rpcport=18544, extra_args=None
|
||||
request, rpcport=18544, extra_args=None
|
||||
)
|
||||
try:
|
||||
assert bitcoind_regtest.get_rpc().test_connection()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import json, logging, pytest, time, os
|
|||
from cryptoadvance.specter.specter import Specter
|
||||
from cryptoadvance.specter.wallet import Wallet
|
||||
from cryptoadvance.specter.managers.wallet_manager import WalletManager
|
||||
from conftest import instantiate_bitcoind_controller
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@ from cryptoadvance.specter.managers.wallet_manager import WalletManager
|
|||
from cryptoadvance.specter.specter_error import SpecterError
|
||||
from cryptoadvance.specter.util.descriptor import AddChecksum, Descriptor
|
||||
from cryptoadvance.specter.util.wallet_importer import WalletImporter
|
||||
from conftest import instantiate_bitcoind_controller
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_WalletManager(
|
||||
docker,
|
||||
request,
|
||||
devices_filled_data_folder,
|
||||
device_manager,
|
||||
|
|
@ -119,7 +117,6 @@ def test_WalletManager(
|
|||
@pytest.mark.bottleneck
|
||||
@pytest.mark.threading
|
||||
def test_WalletManager_2_nodes(
|
||||
docker,
|
||||
request,
|
||||
devices_filled_data_folder,
|
||||
device_manager,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ import logging
|
|||
import os
|
||||
|
||||
import pytest
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
||||
BitcoindPlainController,
|
||||
)
|
||||
|
|
@ -61,7 +58,7 @@ def test_fetch_wallet_addresses_for_mining(caplog, wallets_filled_data_folder):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_node_running_elements(caplog, docker, request):
|
||||
def test_node_running_elements(caplog, request):
|
||||
# TODO: Refactor this to use conftest.instantiate_bitcoind_controller
|
||||
# to reduce redundant code?
|
||||
caplog.set_level(logging.INFO)
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ def test_specter(specter_regtest_configured, caplog):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_abandon_purged_tx(
|
||||
caplog, docker, request, devices_filled_data_folder, device_manager
|
||||
):
|
||||
def test_abandon_purged_tx(caplog, request, devices_filled_data_folder, device_manager):
|
||||
# Specter should support calling abandontransaction if a pending tx has been purged
|
||||
# from the mempool. Test starts a new bitcoind with a restricted mempool to make it
|
||||
# easier to spam the mempool and purge our target tx.
|
||||
|
|
@ -53,7 +51,6 @@ def test_abandon_purged_tx(
|
|||
# Instantiate a new bitcoind w/limited mempool. Use a different port to not interfere
|
||||
# with existing instance for other tests.
|
||||
bitcoind_controller = instantiate_bitcoind_controller(
|
||||
docker,
|
||||
request,
|
||||
rpcport=18998,
|
||||
extra_args=["-acceptnonstdtxn=1", "-maxmempool=5", "-spendzeroconfchange=0"],
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ from cryptoadvance.specter.managers.user_manager import UserManager
|
|||
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
||||
BitcoindPlainController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.elementsd_controller import (
|
||||
ElementsPlainController,
|
||||
)
|
||||
|
|
@ -61,7 +58,6 @@ def pytest_addoption(parser):
|
|||
see pytest_generate_tests(metafunc) on how to check that
|
||||
Also used to register the SIGUSR2 (12) as decribed in conftest.py
|
||||
"""
|
||||
parser.addoption("--docker", action="store_true", help="run bitcoind in docker")
|
||||
parser.addoption(
|
||||
"--bitcoind-version",
|
||||
action="store",
|
||||
|
|
@ -86,39 +82,34 @@ def pytest_addoption(parser):
|
|||
def pytest_generate_tests(metafunc):
|
||||
# ToDo: use custom compiled version of bitcoind
|
||||
# E.g. test again bitcoind version [currentRelease] + master-branch
|
||||
if "docker" in metafunc.fixturenames:
|
||||
if metafunc.config.getoption("docker"):
|
||||
# That's a list because we could do both (see above) but currently that doesn't make sense in that context
|
||||
metafunc.parametrize("docker", [True], scope="session")
|
||||
else:
|
||||
metafunc.parametrize("docker", [False], scope="session")
|
||||
|
||||
# docker support is removed but keep this as an example on how to vary tests
|
||||
|
||||
# if "docker" in metafunc.fixturenames:
|
||||
# if metafunc.config.getoption("docker"):
|
||||
# # That's a list because we could do both (see above) but currently that doesn't make sense in that context
|
||||
# metafunc.parametrize("docker", [True], scope="session")
|
||||
# else:
|
||||
# metafunc.parametrize("docker", [False], scope="session")
|
||||
pass
|
||||
|
||||
|
||||
def instantiate_bitcoind_controller(docker, request, rpcport=18543, extra_args=[]):
|
||||
def instantiate_bitcoind_controller(request, rpcport=18543, extra_args=[]):
|
||||
# logging.getLogger().setLevel(logging.DEBUG)
|
||||
requested_version = request.config.getoption("--bitcoind-version")
|
||||
log_stdout = str2bool(request.config.getoption("--bitcoind-log-stdout"))
|
||||
if docker:
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
|
||||
bitcoind_controller = BitcoindDockerController(
|
||||
rpcport=rpcport, docker_tag=requested_version
|
||||
)
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller.start_bitcoind(
|
||||
cleanup_at_exit=True,
|
||||
cleanup_hard=True,
|
||||
|
|
@ -178,8 +169,8 @@ def bitcoind_path():
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bitcoin_regtest(docker, request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(docker, request, extra_args=None)
|
||||
def bitcoin_regtest(request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(request, extra_args=None)
|
||||
try:
|
||||
assert bitcoind_regtest.get_rpc().test_connection()
|
||||
assert not bitcoind_regtest.datadir is None
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ from cryptoadvance.specter.managers.user_manager import UserManager
|
|||
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
||||
BitcoindPlainController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.elementsd_controller import (
|
||||
ElementsPlainController,
|
||||
)
|
||||
|
|
@ -94,31 +91,22 @@ def pytest_generate_tests(metafunc):
|
|||
metafunc.parametrize("docker", [False], scope="session")
|
||||
|
||||
|
||||
def instantiate_bitcoind_controller(docker, request, rpcport=18543, extra_args=[]):
|
||||
def instantiate_bitcoind_controller(request, rpcport=18543, extra_args=[]):
|
||||
# logging.getLogger().setLevel(logging.DEBUG)
|
||||
requested_version = request.config.getoption("--bitcoind-version")
|
||||
log_stdout = str2bool(request.config.getoption("--bitcoind-log-stdout"))
|
||||
if docker:
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
|
||||
bitcoind_controller = BitcoindDockerController(
|
||||
rpcport=rpcport, docker_tag=requested_version
|
||||
)
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller.start_bitcoind(
|
||||
cleanup_at_exit=True,
|
||||
cleanup_hard=True,
|
||||
|
|
@ -178,8 +166,8 @@ def bitcoind_path():
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bitcoin_regtest(docker, request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(docker, request, extra_args=None)
|
||||
def bitcoin_regtest(request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(request, extra_args=None)
|
||||
try:
|
||||
assert bitcoind_regtest.get_rpc().test_connection()
|
||||
assert not bitcoind_regtest.datadir is None
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ from cryptoadvance.specter.managers.user_manager import UserManager
|
|||
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
||||
BitcoindPlainController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
from cryptoadvance.specter.process_controller.elementsd_controller import (
|
||||
ElementsPlainController,
|
||||
)
|
||||
|
|
@ -61,7 +58,6 @@ def pytest_addoption(parser):
|
|||
see pytest_generate_tests(metafunc) on how to check that
|
||||
Also used to register the SIGUSR2 (12) as decribed in conftest.py
|
||||
"""
|
||||
parser.addoption("--docker", action="store_true", help="run bitcoind in docker")
|
||||
parser.addoption(
|
||||
"--bitcoind-version",
|
||||
action="store",
|
||||
|
|
@ -98,27 +94,18 @@ def instantiate_bitcoind_controller(docker, request, rpcport=18543, extra_args=[
|
|||
# logging.getLogger().setLevel(logging.DEBUG)
|
||||
requested_version = request.config.getoption("--bitcoind-version")
|
||||
log_stdout = str2bool(request.config.getoption("--bitcoind-log-stdout"))
|
||||
if docker:
|
||||
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
||||
BitcoindDockerController,
|
||||
)
|
||||
|
||||
bitcoind_controller = BitcoindDockerController(
|
||||
rpcport=rpcport, docker_tag=requested_version
|
||||
)
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
if os.path.isfile("tests/bitcoin/src/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/src/bitcoind", rpcport=rpcport
|
||||
) # always prefer the self-compiled bitcoind if existing
|
||||
elif os.path.isfile("tests/bitcoin/bin/bitcoind"):
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
bitcoind_path="tests/bitcoin/bin/bitcoind", rpcport=rpcport
|
||||
) # next take the self-installed binary if existing
|
||||
else:
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller = BitcoindPlainController(
|
||||
rpcport=rpcport
|
||||
) # Alternatively take the one on the path for now
|
||||
bitcoind_controller.start_bitcoind(
|
||||
cleanup_at_exit=True,
|
||||
cleanup_hard=True,
|
||||
|
|
@ -178,8 +165,8 @@ def bitcoind_path():
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def bitcoin_regtest(docker, request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(docker, request, extra_args=None)
|
||||
def bitcoin_regtest(request):
|
||||
bitcoind_regtest = instantiate_bitcoind_controller(request, extra_args=None)
|
||||
try:
|
||||
assert bitcoind_regtest.get_rpc().test_connection()
|
||||
assert not bitcoind_regtest.datadir is None
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ Subcommands:
|
|||
|
||||
generic-options:
|
||||
--debug Run as much stuff in debug as we can
|
||||
--docker Run bitcoind in docker instead of directly
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +155,6 @@ function start_node {
|
|||
addopts="--log-stdout"
|
||||
fi
|
||||
fi
|
||||
if [ "$DOCKER" != "true" ]; then
|
||||
if [ "$node_impl" != "elementsd" ]; then # no docker for elementsd yet
|
||||
addopts="$addopts --nodocker"
|
||||
fi
|
||||
fi
|
||||
echo "--> Starting $node_impl with $addopts ..."
|
||||
python3 -m cryptoadvance.specter $DEBUG $node_impl $addopts --no-mining --port $node_port --create-conn-json --config $SPECTER_CONFIG &
|
||||
if [ "$node_impl" = "bitcoind" ]; then
|
||||
|
|
@ -419,10 +413,6 @@ function parse_and_execute() {
|
|||
ELMLOGSTDOUT=true
|
||||
shift
|
||||
;;
|
||||
--docker)
|
||||
DOCKER=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
START=$(date +%s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue