diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a67e6f..e0e3b58 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,21 +18,15 @@ jobs: steps: - checkout - # Get bitcoin_sandbox - - run: - name: Get bitcoin_sandbox - command: git clone --single-branch --branch ln https://github.com/sr-gi/bitcoin_sandbox.git - # Download and cache dependencies - restore_cache: keys: - - v2-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "bitcoin_sandbox/requirements.txt" }} - # fallback to using the latest cache if no exact match is found - - v2-dependencies- + - v1-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "test/pisa/e2e/bitcoind_snap.sh" }} - run: name: Install dependencies command: | + sudo snap install `cat test/pisa/e2e/bitcoind_snap.sh` pyenv local 3.7.0 python3 -m venv venv . venv/bin/activate @@ -40,23 +34,12 @@ jobs: pip install -r pisa/requirements.txt pip install -r pisa/requirements-dev.txt pip install -r apps/cli/requirements-dev.txt - pip install -r bitcoin_sandbox/requirements.txt - save_cache: paths: - ./venv - key: v2-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "bitcoin_sandbox/requirements.txt" }} - - # Build docker env for E2E testing - - run: - name: Build bitcoin_sandbox - command: | - cp test/pisa/e2e/bitcoin.conf bitcoin_sandbox/ - cp test/pisa/e2e/sandbox-conf.py bitcoin_sandbox/bitcoin_sandbox/conf.py - cp bitcoin_sandbox/docker/Dockerfile_ubuntu_no_ln bitcoin_sandbox/Dockerfile - . venv/bin/activate - cd bitcoin_sandbox && python -m bitcoin_sandbox.run_scenarios - + - /snap + key: v1-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "test/pisa/e2e/bitcoind_snap.sh" }} # Run unit tests - run: @@ -83,6 +66,14 @@ jobs: . venv/bin/activate pytest test/apps/cli/unit + # Run bitcoind for E2E testing + - run: + name: Run bitcoind + command: | + mkdir -p /home/circleci/snap/bitcoin-core/common/.bitcoin/ + cp test/pisa/e2e/bitcoin.conf /home/circleci/snap/bitcoin-core/common/.bitcoin/ + /snap/bin/bitcoin-core.daemon + # Setup pisa for E2E testing - run: name: Setup pisa diff --git a/apps/cli/README.md b/apps/cli/README.md index 1f1f023..1926f01 100644 --- a/apps/cli/README.md +++ b/apps/cli/README.md @@ -145,3 +145,14 @@ or ## the Eye of Satoshi's API If you wish to read about the underlying API, and how to write your own tool to interact with it, refer to [tEOS-API.md](tEOS-API.md). + +## Are you reckless? Try me on mainnet +Would you like to try me on `mainnet` instead of `testnet`? Add `-s https://mainnet.teos.pisa.watch` to your calls, for example: + +``` +python wt_cli.py -s https://teosmainnet.pisa.watch add_appointment -f dummy_appointment_data.json +``` + +You can also change the config file to avoid specifying the server every time: + +`DEFAULT_PISA_API_SERVER = "https://teosmainnet.pisa.watch"` \ No newline at end of file diff --git a/apps/cli/requirements-dev.txt b/apps/cli/requirements-dev.txt index 3b5f741..f8c47f0 100644 --- a/apps/cli/requirements-dev.txt +++ b/apps/cli/requirements-dev.txt @@ -1 +1,3 @@ -responses \ No newline at end of file +responses +pytest +black \ No newline at end of file diff --git a/test/common/unit/test_tools.py b/test/common/unit/test_tools.py index 8b613ae..eb303c1 100644 --- a/test/common/unit/test_tools.py +++ b/test/common/unit/test_tools.py @@ -3,6 +3,7 @@ import pytest import logging from copy import deepcopy +# FIXME: Import from pisa. Common should not import anything from cli nor pisa. from pisa import conf_fields from common.constants import LOCATOR_LEN_BYTES diff --git a/test/pisa/e2e/bitcoin.conf b/test/pisa/e2e/bitcoin.conf index 92c9105..e11a3ed 100644 --- a/test/pisa/e2e/bitcoin.conf +++ b/test/pisa/e2e/bitcoin.conf @@ -2,6 +2,7 @@ dnsseed=0 # [debug] +daemon=1 regtest=1 debug=1 logips=1 diff --git a/test/pisa/e2e/bitcoind_snap.sh b/test/pisa/e2e/bitcoind_snap.sh new file mode 100644 index 0000000..78915c2 --- /dev/null +++ b/test/pisa/e2e/bitcoind_snap.sh @@ -0,0 +1 @@ +bitcoin-core --channel=0.19/stable \ No newline at end of file diff --git a/test/pisa/e2e/pisa-conf.py b/test/pisa/e2e/pisa-conf.py index f53a81b..3c219c1 100644 --- a/test/pisa/e2e/pisa-conf.py +++ b/test/pisa/e2e/pisa-conf.py @@ -2,13 +2,13 @@ BTC_RPC_USER = "user" BTC_RPC_PASSWD = "passwd" BTC_RPC_HOST = "localhost" -BTC_RPC_PORT = 18445 +BTC_RPC_PORT = 18443 BTC_NETWORK = "regtest" # ZMQ FEED_PROTOCOL = "tcp" FEED_ADDR = "127.0.0.1" -FEED_PORT = 28335 +FEED_PORT = 28332 # PISA DATA_FOLDER = "~/.pisa_btc/" diff --git a/test/pisa/e2e/sandbox-conf.py b/test/pisa/e2e/sandbox-conf.py deleted file mode 100644 index cbdd3d0..0000000 --- a/test/pisa/e2e/sandbox-conf.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copy this file with your own configuration and save it as conf.py - -# Docker -DOCK_NETWORK_NAME = "pisa_net" -DOCK_NETWORK_SUBNET = "172.16.0.0/16" -DOCK_NETWORK_GW = "172.16.0.1" -DOCK_CONTAINER_NAME_PREFIX = "btc_n" -DOCK_IMAGE_NAME = "sandbox_btc" -DOCKER_INI_PORT_MAPPING = 22000 -DOCKER_RPC_PORT_MAPPING = 18444 -DOCKER_ZMQ_BLOCK_PORT_MAPPING = 28334 - -# Log -LOG_FILE = "bitcoin_sandbox.log" - -# Graphs -BITCOIN_GRAPH_FILE = "./graphs/basic3.graphml" -LN_GRAPH_FILE = "./graphs/basic3_ln.graphml" -DEFAULT_LN_GRAPH_WEIGHT = 10000