mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-29 02:01:35 +02:00
CI: regtest with LndRestWallet
and CLightningWallet
(#738)
* add regtest * test LndRestWallet * test CLightningWallet
This commit is contained in:
97
.github/workflows/regtest.yml
vendored
Normal file
97
.github/workflows/regtest.yml
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
name: regtest
|
||||||
|
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
LndRestWallet:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Setup Regtest
|
||||||
|
run: |
|
||||||
|
docker build -t lnbits-legend .
|
||||||
|
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
|
||||||
|
cd docker
|
||||||
|
source docker-scripts.sh
|
||||||
|
lnbits-regtest-start
|
||||||
|
echo "sleeping 60 seconds"
|
||||||
|
sleep 60
|
||||||
|
echo "continue"
|
||||||
|
lnbits-regtest-init
|
||||||
|
bitcoin-cli-sim -generate 1
|
||||||
|
lncli-sim 1 listpeers
|
||||||
|
sudo chmod -R a+rwx .
|
||||||
|
- name: Install dependencies
|
||||||
|
env:
|
||||||
|
VIRTUAL_ENV: ./venv
|
||||||
|
PATH: ${{ env.VIRTUAL_ENV }}/bin:${{ env.PATH }}
|
||||||
|
run: |
|
||||||
|
python -m venv ${{ env.VIRTUAL_ENV }}
|
||||||
|
./venv/bin/python -m pip install --upgrade pip
|
||||||
|
./venv/bin/pip install -r requirements.txt
|
||||||
|
./venv/bin/pip install pylightning
|
||||||
|
./venv/bin/pip install pytest pytest-asyncio pytest-cov requests mock
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
PORT: 5123
|
||||||
|
LNBITS_DATA_FOLDER: ./data
|
||||||
|
LNBITS_BACKEND_WALLET_CLASS: LndRestWallet
|
||||||
|
LND_REST_ENDPOINT: https://localhost:8081/
|
||||||
|
LND_REST_CERT: docker/data/lnd-1/tls.cert
|
||||||
|
LND_REST_MACAROON: docker/data/lnd-1/data/chain/bitcoin/regtest/admin.macaroon
|
||||||
|
run: |
|
||||||
|
sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data
|
||||||
|
make test-real-wallet
|
||||||
|
CLightningWallet:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Setup Regtest
|
||||||
|
run: |
|
||||||
|
docker build -t lnbits-legend .
|
||||||
|
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
|
||||||
|
cd docker
|
||||||
|
source docker-scripts.sh
|
||||||
|
lnbits-regtest-start
|
||||||
|
echo "sleeping 60 seconds"
|
||||||
|
sleep 60
|
||||||
|
echo "continue"
|
||||||
|
lnbits-regtest-init
|
||||||
|
bitcoin-cli-sim -generate 1
|
||||||
|
lncli-sim 1 listpeers
|
||||||
|
sudo chmod -R a+rwx .
|
||||||
|
- name: Install dependencies
|
||||||
|
env:
|
||||||
|
VIRTUAL_ENV: ./venv
|
||||||
|
PATH: ${{ env.VIRTUAL_ENV }}/bin:${{ env.PATH }}
|
||||||
|
run: |
|
||||||
|
python -m venv ${{ env.VIRTUAL_ENV }}
|
||||||
|
./venv/bin/python -m pip install --upgrade pip
|
||||||
|
./venv/bin/pip install -r requirements.txt
|
||||||
|
./venv/bin/pip install pylightning
|
||||||
|
./venv/bin/pip install pytest pytest-asyncio pytest-cov requests mock
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
PORT: 5123
|
||||||
|
LNBITS_DATA_FOLDER: ./data
|
||||||
|
LNBITS_BACKEND_WALLET_CLASS: CLightningWallet
|
||||||
|
CLIGHTNING_RPC: docker/data/clightning-1/regtest/lightning-rpc
|
||||||
|
run: |
|
||||||
|
sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data
|
||||||
|
make test-real-wallet
|
21
Makefile
21
Makefile
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
all: format check requirements.txt
|
all: format check requirements.txt
|
||||||
|
|
||||||
format: prettier black
|
format: prettier isort black
|
||||||
|
|
||||||
check: mypy checkprettier checkblack
|
check: mypy checkprettier checkblack
|
||||||
|
|
||||||
@ -17,12 +17,18 @@ mypy: $(shell find lnbits -name "*.py")
|
|||||||
./venv/bin/mypy lnbits/core
|
./venv/bin/mypy lnbits/core
|
||||||
./venv/bin/mypy lnbits/extensions/*
|
./venv/bin/mypy lnbits/extensions/*
|
||||||
|
|
||||||
|
isort: $(shell find lnbits -name "*.py")
|
||||||
|
./venv/bin/isort --profile black lnbits
|
||||||
|
|
||||||
checkprettier: $(shell find lnbits -name "*.js" -name ".html")
|
checkprettier: $(shell find lnbits -name "*.js" -name ".html")
|
||||||
./node_modules/.bin/prettier --check lnbits/static/js/*.js lnbits/core/static/js/*.js lnbits/extensions/*/templates/*/*.html ./lnbits/core/templates/core/*.html lnbits/templates/*.html lnbits/extensions/*/static/js/*.js
|
./node_modules/.bin/prettier --check lnbits/static/js/*.js lnbits/core/static/js/*.js lnbits/extensions/*/templates/*/*.html ./lnbits/core/templates/core/*.html lnbits/templates/*.html lnbits/extensions/*/static/js/*.js
|
||||||
|
|
||||||
checkblack: $(shell find lnbits -name "*.py")
|
checkblack: $(shell find lnbits -name "*.py")
|
||||||
./venv/bin/black --check lnbits
|
./venv/bin/black --check lnbits
|
||||||
|
|
||||||
|
checkisort: $(shell find lnbits -name "*.py")
|
||||||
|
./venv/bin/isort --profile black --check-only lnbits
|
||||||
|
|
||||||
Pipfile.lock: Pipfile
|
Pipfile.lock: Pipfile
|
||||||
./venv/bin/pipenv lock
|
./venv/bin/pipenv lock
|
||||||
|
|
||||||
@ -32,18 +38,27 @@ requirements.txt: Pipfile.lock
|
|||||||
test:
|
test:
|
||||||
rm -rf ./tests/data
|
rm -rf ./tests/data
|
||||||
mkdir -p ./tests/data
|
mkdir -p ./tests/data
|
||||||
|
LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \
|
||||||
FAKE_WALLET_SECRET="ToTheMoon1" \
|
FAKE_WALLET_SECRET="ToTheMoon1" \
|
||||||
LNBITS_DATA_FOLDER="./tests/data" \
|
LNBITS_DATA_FOLDER="./tests/data" \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
./venv/bin/pytest --durations=1 -s --cov=lnbits --cov-report=xml
|
./venv/bin/pytest --durations=1 -s --cov=lnbits --cov-report=xml tests
|
||||||
|
|
||||||
|
test-real-wallet:
|
||||||
|
rm -rf ./tests/data
|
||||||
|
mkdir -p ./tests/data
|
||||||
|
LNBITS_DATA_FOLDER="./tests/data" \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
./venv/bin/pytest --durations=1 -s --cov=lnbits --cov-report=xml tests
|
||||||
|
|
||||||
test-pipenv:
|
test-pipenv:
|
||||||
rm -rf ./tests/data
|
rm -rf ./tests/data
|
||||||
mkdir -p ./tests/data
|
mkdir -p ./tests/data
|
||||||
|
LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \
|
||||||
FAKE_WALLET_SECRET="ToTheMoon1" \
|
FAKE_WALLET_SECRET="ToTheMoon1" \
|
||||||
LNBITS_DATA_FOLDER="./tests/data" \
|
LNBITS_DATA_FOLDER="./tests/data" \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
pipenv run pytest --durations=1 -s --cov=lnbits --cov-report=xml
|
pipenv run pytest --durations=1 -s --cov=lnbits --cov-report=xml tests
|
||||||
|
|
||||||
bak:
|
bak:
|
||||||
# LNBITS_DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5432/postgres
|
# LNBITS_DATABASE_URL=postgres://postgres:postgres@0.0.0.0:5432/postgres
|
||||||
|
@ -27,7 +27,8 @@ WALLET.status = AsyncMock(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
WALLET.create_invoice = generate_mock_invoice
|
# Note: if this line is uncommented, invoices will always be generated by FakeWallet
|
||||||
|
# WALLET.create_invoice = generate_mock_invoice
|
||||||
|
|
||||||
# NOTE: This mock fails since it yields the same invoice multiple
|
# NOTE: This mock fails since it yields the same invoice multiple
|
||||||
# times which makes the db throw an error due to uniqueness contraints
|
# times which makes the db throw an error due to uniqueness contraints
|
||||||
|
Reference in New Issue
Block a user