Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile with test requirements #125

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM lnregtest:local as lnregtest-deps
FROM lndmanage:local

COPY --from=lnregtest-deps /opt/bin/ /root/lndmanage/test/bin/
ENV PATH="/root/.venv/bin:/opt/bin:$PATH:/root"
ARG LNREGTEST_REF=be7f39b306829387b3e9754e84db60901fbb385e
RUN apt-get update && \
apt-get install -y -q --no-install-recommends git && \
pip install git+https://github.com/bitromortac/lnregtest.git@${LNREGTEST_REF} && \
apt-get purge -y --autoremove git && \
rm -rf /var/lib/apt/lists/*

WORKDIR /root/lndmanage

ENTRYPOINT [ "/root/.venv/bin/python3", "-m", "unittest","discover", "test" ]
14 changes: 6 additions & 8 deletions test/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from typing import List
import unittest

from test.testing_common import (
test_graphs_paths,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork,
)

from lndmanage.lib.listings import ListChannels
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.exceptions import (
Expand All @@ -17,15 +23,7 @@
)
from lndmanage import settings

from test.testing_common import (
test_graphs_paths,
lndmanage_home,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork,
)

import logging.config
settings.set_lndmanage_home_dir(lndmanage_home)
logging.config.dictConfig(settings.logger_config)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions test/test_fee_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import sys

from test import testing_common
from lndmanage.lib.fee_setting import delta_demand, delta_min, optimization_parameters

logger = logging.getLogger()
Expand Down
1 change: 1 addition & 0 deletions test/test_graph_definitions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase

from test import testing_common
from lnregtest.lib.graph_testing import graph_test
from test.graph_definitions.star_ring_4_illiquid import nodes

Expand Down
1 change: 1 addition & 0 deletions test/test_ln_utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from test import testing_common
from lndmanage.lib.ln_utilities import (
local_balance_to_unbalancedness,
unbalancedness_to_local_balance,
Expand Down
8 changes: 3 additions & 5 deletions test/test_openchannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
import time
from unittest import TestCase

from lndmanage import settings
from lndmanage.lib import openchannels

from test.testing_common import (
lndmanage_home,
test_graphs_paths,
TestNetwork,
)

from lndmanage import settings
from lndmanage.lib import openchannels

import logging.config

settings.set_lndmanage_home_dir(lndmanage_home)
logging.config.dictConfig(settings.logger_config)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Expand Down
2 changes: 2 additions & 0 deletions test/test_pathfinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import networkx as nx

from test import testing_common

from lndmanage.lib.network import Network
from lndmanage.lib.rating import ChannelRater
from lndmanage.lib.pathfinding import dijkstra
Expand Down
1 change: 1 addition & 0 deletions test/test_psbt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from test import testing_common
from lndmanage.lib import psbt
from binascii import unhexlify, a2b_base64

Expand Down
1 change: 1 addition & 0 deletions test/test_rating.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

from test import testing_common
from lndmanage.lib.rating import node_badness


Expand Down
12 changes: 5 additions & 7 deletions test/test_rebalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
import time
from typing import Optional

from lndmanage import settings
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
from lndmanage.lib.exceptions import NoRebalanceCandidates

from test.testing_common import (
lndmanage_home,
test_graphs_paths,
SLEEP_SEC_AFTER_REBALANCING,
TestNetwork
)

from lndmanage import settings
from lndmanage.lib.rebalance import Rebalancer
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
from lndmanage.lib.exceptions import NoRebalanceCandidates

import logging.config
settings.set_lndmanage_home_dir(lndmanage_home)
logging.config.dictConfig(settings.logger_config)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Expand Down
30 changes: 18 additions & 12 deletions test/testing_common.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import os
import shutil
from unittest import TestCase

from lnregtest.lib.network import Network

from lib.node import LndNode
from lndmanage import settings

settings.CACHING_RETENTION_MINUTES = 0

# constants for testing
SLEEP_SEC_AFTER_REBALANCING = 2

# testing base folder
test_dir = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -22,6 +10,24 @@
# folder exists
lndmanage_home = os.path.join(test_data_dir, 'lndmanage')
os.makedirs(lndmanage_home, exist_ok=True)
# create empty config and set env var to not trigger error when importing settings
open(os.path.join(lndmanage_home, 'config.ini'), 'a').close()

os.environ.setdefault('LNDMANAGE_HOME', lndmanage_home)

import shutil
from unittest import TestCase

from lnregtest.lib.network import Network

from lndmanage.lib.node import LndNode
from lndmanage import settings

settings.CACHING_RETENTION_MINUTES = 0
settings.set_lndmanage_home_dir(lndmanage_home)

# constants for testing
SLEEP_SEC_AFTER_REBALANCING = 2

test_graphs_paths = {
'star_ring_3_liquid': os.path.join(
Expand Down