Skip to content

Commit

Permalink
Add django utils tests (#911)
Browse files Browse the repository at this point in the history
* Add util tests

* Enable coordinator test workflow
  • Loading branch information
Reckless-Satoshi authored Oct 23, 2023
1 parent e0fed23 commit 54a5987
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env-sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Coordinator Alias (Same as longAlias)
COORDINATOR_ALIAS="Local Dev"
# Lightning node vendor: CLN | LND
LNVENDOR='CLN'
LNVENDOR='LND'

# LND directory to read TLS cert and macaroon
LND_DIR='/lnd/'
Expand Down
47 changes: 39 additions & 8 deletions .github/workflows/django-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
push:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats"]
pull_request:
pull_request_target:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats"]

# concurrency:
# group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
# cancel-in-progress: true
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
build:
Expand All @@ -22,24 +22,55 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]
python-version: ["3.11.6"] # , "3.12"]

services:
db:
image: postgres:14.2
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

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

- 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@v2
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
- name: 'Install LND gRPC Dependencies'
- name: 'Install LND/CLN gRPC Dependencies'
run: bash ./scripts/generate_grpc.sh

- name: 'Create .env File'
run: |
mv .env-sample .env
- name: 'Tests'
- 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: 'Run tests with coverage'
run: |
python manage.py test
pip install coverage
coverage run manage.py test
coverage report
2 changes: 1 addition & 1 deletion .github/workflows/py-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11.6'
cache: pip
- run: pip install black==22.8.0 flake8==5.0.4 isort==5.10.1
- name: Run linters
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
fi
# django-test:
# uses: RoboSats/robosats/.github/workflows/django-test.yml@main
# needs: check-versions
django-test:
uses: RoboSats/robosats/.github/workflows/django-test.yml@main
needs: check-versions

frontend-build:
uses: RoboSats/robosats/.github/workflows/frontend-build.yml@main
Expand Down
4 changes: 2 additions & 2 deletions api/lightning/cln.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from decouple import config
from django.utils import timezone

from . import node_pb2 as noderpc
from . import node_pb2_grpc as nodestub
from . import hold_pb2 as holdrpc
from . import hold_pb2_grpc as holdstub
from . import node_pb2 as noderpc
from . import node_pb2_grpc as nodestub
from . import primitives_pb2 as primitives__pb2

#######
Expand Down
3 changes: 0 additions & 3 deletions api/tests.py

This file was deleted.

Empty file added api/tests/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions api/tests/test_enc_priv_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN PGP PRIVATE KEY BLOCK-----

xYYEZTWJ1xYJKwYBBAHaRw8BAQdAsfdKb90BurKniu+pBPBDHCkzg08S51W0
mUR0SKqLmdj+CQMICrS3TNCA/LHgxckC+iTUMxkqQJ9GpXWCDacx1rBQCztu
PDgUHNvWdcvW1wWVxU/aJaQLqBTtRVYkJTz332jrKvsSl/LnrfwmUfKgN4nG
Oc1MUm9ib1NhdHMgSUQgNTUyZGQxYTY2MWE3YWNhNGE0MWY4ODkxMGZmMzRh
YzNiMWFjODBiYjc3OTRlZDlmZDU1ZDhiNzZiOTdhYWQ5N8KMBBAWCgA+BYJl
NYnXBAsJBwgJkDc3tq7iCL/OAxUICgQWAAIBAhkBApsDAh4BFiEE7mIEuePQ
n8Tqye0QNze2ruIIv84AAORXAQD+0G30U+qvEsc48W3JTKmmmvT+3q+uXdGs
vMIuqoTWdQD/R+aGKvYXzwpyzGYInAAOj8WCXBcYWSOtXiw/oWNgEQHHiwRl
NYnXEgorBgEEAZdVAQUBAQdALJQh7exBNphr8gU0oY2ZfP/6Gse6Ryi3hM6+
LZsP2nwDAQgH/gkDCPPoYWyzm4mT4N/TDBF11GVq0xSEEcubFqjArFKyibRy
TDnB8+o8BlkRuGClcfRyKkR5/Rp1v5B0n1BuMsc8nY4Yg4BJv4KhsPfXRp4m
31zCeAQYFggAKgWCZTWJ1wmQNze2ruIIv84CmwwWIQTuYgS549CfxOrJ7RA3
N7au4gi/zgAAmhQA+wRtxO05FKFirSXuTj808F/mzF8u4Wz0kMNMzPUXvCj9
AQCHkxvHdvNHUyut4f7HkACnjI9M3+wGF69ArHL0u39/Aw==
=1hCT
-----END PGP PRIVATE KEY BLOCK-----
14 changes: 14 additions & 0 deletions api/tests/test_pub_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mDMEZTWJ1xYJKwYBBAHaRw8BAQdAsfdKb90BurKniu+pBPBDHCkzg08S51W0mUR0
SKqLmdi0TFJvYm9TYXRzIElEIDU1MmRkMWE2NjFhN2FjYTRhNDFmODg5MTBmZjM0
YWMzYjFhYzgwYmI3Nzk0ZWQ5ZmQ1NWQ4Yjc2Yjk3YWFkOTeIjAQQFgoAPgWCZTWJ
1wQLCQcICZA3N7au4gi/zgMVCAoEFgACAQIZAQKbAwIeARYhBO5iBLnj0J/E6snt
EDc3tq7iCL/OAADkVwEA/tBt9FPqrxLHOPFtyUypppr0/t6vrl3RrLzCLqqE1nUA
/0fmhir2F88KcsxmCJwADo/FglwXGFkjrV4sP6FjYBEBuDgEZTWJ1xIKKwYBBAGX
VQEFAQEHQCyUIe3sQTaYa/IFNKGNmXz/+hrHukcot4TOvi2bD9p8AwEIB4h4BBgW
CAAqBYJlNYnXCZA3N7au4gi/zgKbDBYhBO5iBLnj0J/E6sntEDc3tq7iCL/OAACa
FAD7BG3E7TkUoWKtJe5OPzTwX+bMXy7hbPSQw0zM9Re8KP0BAIeTG8d280dTK63h
/seQAKeMj0zf7AYXr0CscvS7f38D
=+xY8
-----END PGP PUBLIC KEY BLOCK-----
11 changes: 11 additions & 0 deletions api/tests/test_signed_message
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

test
-----BEGIN PGP SIGNATURE-----

wnUEARYKACcFgmU22/EJkDc3tq7iCL/OFiEE7mIEuePQn8Tqye0QNze2ruII
v84AAJDMAP9JXQJNRYUiPaSroIfmfJccPQeaVuHTnl0fJqLToL6GbAD/Rt7c
Y67Co6RJi70vytMorPKWmiX6C/mrnKL0auQC8gQ=
=1ouc
-----END PGP SIGNATURE-----
Loading

0 comments on commit 54a5987

Please sign in to comment.