Skip to content

Commit

Permalink
Add CLN regtest to integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Nov 13, 2023
1 parent 11a547e commit 07f0f0b
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 167 deletions.
93 changes: 44 additions & 49 deletions .github/workflows/django-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,63 @@ concurrency:
cancel-in-progress: true

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
max-parallel: 1
matrix:
python-version: ["3.11.6", "3.12"]
lnd-version: ["v0.17.0-beta","v0.17.1-beta.rc1"]
python-tag: ['3.11.6-slim-bookworm', '3.12-slim-bookworm']
lnd-version: ["v0.17.0-beta", "v0.17.0-beta.rc1"]
cln-version: ["v23.08.1"]
ln-vendor: ["LND", "CLN"]
# bitcoind-version: ["24.0.1"]
# include:
# - lnd-version: "v0.17.0-beta"
# ln-vendor: "LND"
# - lnd-version: "v0.17.1-beta.rc1"
# ln-vendor: "LND"
# - cln-version: "v23.08.1"
# ln-vendor: "CLN"

steps:
- name: 'Checkout'
uses: actions/checkout@v4

- name: 'Compose Eegtest Orchestration'
- name: Update Python version in Dockerfile
run: |
sed -i "1s/FROM python:.*/FROM python:${{ matrix.python-tag }}/" Dockerfile
cat ./Dockerfile
- name: 'Compose Regtest Orchestration'
uses: isbang/[email protected]
with:
compose-file: "docker-test.yml"
env: "tests/compose.env"

# - name: 'Set up Python ${{ matrix.python-version }}'
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

# - name: 'Cache pip dependencies'
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-

# - name: 'Install Python Dependencies'
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# pip install -r requirements_dev.txt
compose-file: "./docker-tests.yml"
down-flags: "--volumes"
services: |
bitcoind
postgres
redis
coordinator-${{ matrix.ln-vendor }}
robot-LND
coordinator
env:
LND_VERSION: ${{ matrix.lnd-version }}
CLN_VERSION: ${{ matrix.cln-version }}
BITCOIND_VERSION: ${{ matrix.bitcoind-version }}
ROBOSATS_ENVS_FILE: ".env-sample"

# - name: 'Install LND/CLN gRPC Dependencies'
# run: bash ./scripts/generate_grpc.sh

# - name: 'Create .env File'
# run: |
# mv .env-sample .env
# sed -i "s/USE_TOR=True/USE_TOR=False/" .env

# - name: 'Wait for PostgreSQL to become ready'
# run: |
# sudo apt-get install -y postgresql-client
# until pg_isready -h localhost -p 5432 -U postgres; do sleep 2; done
- name: Wait for entrypoint to install dev deps
run: |
while ! docker exec coordinator coverage --version >/dev/null 2>&1; do
echo "Waiting for coverage to be installed..."
sleep 5
done
- name: 'Run tests with coverage'
run: |
docker exec coordinator coverage run manage.py test
docker exec coordinator coverage report
# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Run Docker Compose
# run: |
# docker-compose up -d
# docker-compose run web python manage.py test
env:
LNVENDOR: ${{ matrix.ln-vendor }}
DEVELOPMENT: True
USE_TOR: False
2 changes: 1 addition & 1 deletion .github/workflows/py-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
python-version: '3.11.6'
cache: pip
- run: pip install black==22.8.0 flake8==5.0.4 isort==5.10.1
- run: pip install requirements_dev.txt
- name: Run linters
uses: wearerequired/lint-action@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
fi
django-test:
uses: RoboSats/robosats/.github/workflows/django-test.yml@main
integration-tests:
uses: RoboSats/robosats/.github/workflows/integration-tests.yml@main
needs: check-versions

frontend-build:
Expand Down
10 changes: 10 additions & 0 deletions api/lightning/cln.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ def get_version(cls):
print(f"Cannot get CLN version: {e}")
return None

@classmethod
def get_info(cls):
try:
nodestub = node_pb2_grpc.NodeStub(cls.node_channel)
request = node_pb2.GetinfoRequest()
response = nodestub.Getinfo(request)
return response
except Exception as e:
print(f"Cannot get CLN node id: {e}")

@classmethod
def decode_payreq(cls, invoice):
"""Decodes a lightning payment request (invoice)"""
Expand Down
4 changes: 2 additions & 2 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class InfoSerializer(serializers.Serializer):
lifetime_volume = serializers.FloatField(
help_text="Total volume in BTC since exchange's inception"
)
lnd_version = serializers.CharField(required=False)
cln_version = serializers.CharField(required=False)
lnd_version = serializers.CharField()
cln_version = serializers.CharField()
robosats_running_commit_hash = serializers.CharField()
alternative_site = serializers.CharField()
alternative_name = serializers.CharField()
Expand Down
8 changes: 2 additions & 6 deletions api/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
verify_signed_message,
weighted_median,
)
from tests.mocks.cln import MockNodeStub
from tests.mocks.lnd import MockVersionerStub


class TestUtils(TestCase):
Expand Down Expand Up @@ -96,15 +94,13 @@ def test_get_exchange_rates(self, mock_get_session, mock_config):
mock_response_blockchain.json.assert_called_once()
mock_response_yadio.json.assert_called_once()

@patch("api.lightning.lnd.verrpc_pb2_grpc.VersionerStub", MockVersionerStub)
def test_get_lnd_version(self):
version = get_lnd_version()
self.assertEqual(version, "v0.17.0-beta")
self.assertTrue(isinstance(version, str))

@patch("api.lightning.cln.node_pb2_grpc.NodeStub", MockNodeStub)
def test_get_cln_version(self):
version = get_cln_version()
self.assertEqual(version, "v23.08")
self.assertTrue(isinstance(version, str))

@patch(
"builtins.open", new_callable=mock_open, read_data="00000000000000000000 dev"
Expand Down
4 changes: 2 additions & 2 deletions api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_lnd_version():

return LNDNode.get_version()
except Exception:
return None
return "No LND"


cln_version_cache = {}
Expand All @@ -194,7 +194,7 @@ def get_cln_version():

return CLNNode.get_version()
except Exception:
return None
return "No CLN"


robosats_commit_cache = {}
Expand Down
Loading

0 comments on commit 07f0f0b

Please sign in to comment.