From 67942450e6595a14fb2d22bce30a14dee5aee0cb Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 16 Mar 2020 16:11:08 +0100 Subject: [PATCH 1/5] Add some pending fixes (typos and tests) --- apps/cli/README.md | 11 +++++++++++ apps/cli/requirements-dev.txt | 4 +++- test/common/unit/test_tools.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) 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 From e3521188a7cefd37c32c9deca7b6215ee30eccb1 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 16 Mar 2020 16:31:01 +0100 Subject: [PATCH 2/5] Updates circleci The sandbox won't be needed anymore, so the test env can be made simpler. Forks can be simulated via invalidateblock and reconsiderblock --- .circleci/config.yml | 30 ++++++++++-------------------- test/pisa/e2e/sandbox-conf.py | 19 ------------------- 2 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 test/pisa/e2e/sandbox-conf.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a67e6f..cdb657e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,21 +18,18 @@ 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" }} + - v3-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }} # fallback to using the latest cache if no exact match is found - - v2-dependencies- + - v3-dependencies- - run: name: Install dependencies command: | + sudo apt-get install snapd + sudo snap install bitcoin-core pyenv local 3.7.0 python3 -m venv venv . venv/bin/activate @@ -40,23 +37,11 @@ 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 - + key: v3-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }} # Run unit tests - run: @@ -83,6 +68,11 @@ jobs: . venv/bin/activate pytest test/apps/cli/unit + # Run bitcoind for E2E testing + - run: + name: Run bitcoind + command: bitcoin-core.daemon -conf=test/pisa/e2e/bitcoin.conf + # Setup pisa for E2E testing - run: name: Setup pisa 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 From de6fa5ce1278e348a1fa5305143876869133c26d Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 16 Mar 2020 18:10:56 +0100 Subject: [PATCH 3/5] Further updates circle-ci --- .circleci/config.yml | 15 +++++++++------ test/pisa/e2e/bitcoind_snap.sh | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 test/pisa/e2e/bitcoind_snap.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index cdb657e..ef681dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,15 +21,14 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v3-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }} + - v5-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "test/pisa/e2e/bitcoind_snap.sh" }} # fallback to using the latest cache if no exact match is found - - v3-dependencies- + - v5-dependencies- - run: name: Install dependencies command: | - sudo apt-get install snapd - sudo snap install bitcoin-core + sudo snap install `cat test/pisa/e2e/bitcoind_snap.sh` pyenv local 3.7.0 python3 -m venv venv . venv/bin/activate @@ -41,7 +40,8 @@ jobs: - save_cache: paths: - ./venv - key: v3-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }} + - /snap + key: v5-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: @@ -71,7 +71,10 @@ jobs: # Run bitcoind for E2E testing - run: name: Run bitcoind - command: bitcoin-core.daemon -conf=test/pisa/e2e/bitcoin.conf + 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: 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 From 23dea42bfcc87742304ab3297f4b4542d871f075 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Tue, 17 Mar 2020 11:14:44 +0100 Subject: [PATCH 4/5] Adds daemon to e2e bitcoin.conf --- test/pisa/e2e/bitcoin.conf | 1 + 1 file changed, 1 insertion(+) 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 From 8a0cb4bf2a3ca550c7b113bd2ebe2cebfa498154 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Tue, 17 Mar 2020 11:21:37 +0100 Subject: [PATCH 5/5] Updates pisa.conf for e2e and circle-ci conf --- .circleci/config.yml | 6 ++---- test/pisa/e2e/pisa-conf.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef681dc..e0e3b58 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,9 +21,7 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v5-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "test/pisa/e2e/bitcoind_snap.sh" }} - # fallback to using the latest cache if no exact match is found - - v5-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 @@ -41,7 +39,7 @@ jobs: paths: - ./venv - /snap - key: v5-dependencies-{{ checksum "pisa/requirements.txt" }}-{{ checksum "pisa/requirements-dev.txt" }}-{{ checksum "apps/cli/requirements-dev.txt" }}-{{ checksum "test/pisa/e2e/bitcoind_snap.sh" }} + 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: 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/"