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 e0cb6b6
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 155 deletions.
85 changes: 47 additions & 38 deletions .github/workflows/django-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,77 @@ concurrency:
cancel-in-progress: true

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

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

- name: 'Compose Eegtest Orchestration'
- name: 'Compose Regtest Orchestration'
uses: isbang/[email protected]
with:
compose-file: "docker-test.yml"
env: "tests/compose.env"
compose-file: "./docker-tests.yml"
down-flags: "--volumes"
services: |
bitcoind
postgres
redis
coordinator-lnd
coordinator-cln
robot-lnd
env:
LND_TAG: ${{ matrix.lnd-version }}
CLN_TAG: ${{ matrix.cln-version }}
BITCOIND_TAG: ${{ matrix.bitcoind-version }}
ROBOSATS_ENVS_FILE: ".env-sample"

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

# - name: 'Cache pip dependencies'
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-pip-dev-${{ hashFiles('**/requirements_dev.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
- name: 'Install Python Dependencies'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
# - name: 'Install LND/CLN gRPC Dependencies'
# run: bash ./scripts/generate_grpc.sh
- 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: 'Create .env File'
run: mv .env-sample .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: 'Get permisions on docker volumes'
run: |
sudo chmod -R 777 /var/lib/docker/volumes/robosats_lnd/_data
sudo chmod -R 777 /var/lib/docker/volumes/robosats_cln/_data
- 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
coverage run manage.py test
coverage report
env:
LNVENDOR: ${{ matrix.ln-vendor }}
USE_TOR: False
LND_DIR: '/var/lib/docker/volumes/robosats_lnd/_data'
MACAROON_PATH: 'data/chain/bitcoin/regtest/admin.macaroon'
CLN_DIR: '/var/lib/docker/volumes/robosats_cln/_data/regtest/'
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 e0cb6b6

Please sign in to comment.