Skip to content

Commit d200436

Browse files
author
3nprob
committed
test: Prevent settings from exiting due to missing system lndmanage conf
1 parent 76a29ea commit d200436

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

test/test_circle.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
from typing import List
66
import unittest
77

8+
from test.testing_common import (
9+
test_graphs_paths,
10+
SLEEP_SEC_AFTER_REBALANCING,
11+
TestNetwork,
12+
)
13+
814
from lndmanage.lib.listings import ListChannels
915
from lndmanage.lib.rebalance import Rebalancer
1016
from lndmanage.lib.exceptions import (
@@ -15,12 +21,6 @@
1521
OurNodeFailure,
1622
)
1723

18-
from test.testing_common import (
19-
test_graphs_paths,
20-
SLEEP_SEC_AFTER_REBALANCING,
21-
TestNetwork,
22-
)
23-
2424
from lndmanage import settings # needed for side effect configuration
2525

2626

test/test_fee_setting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import sys
33
import logging
44

5-
from lndmanage.lib.fee_setting import delta_demand, delta_min, optimization_parameters
5+
from test import testing_common
66

7-
import testing_common
7+
from lndmanage.lib.fee_setting import delta_demand, delta_min, optimization_parameters
88

99
testing_common.logger.addHandler(logging.StreamHandler(sys.stdout))
1010

test/test_openchannels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import time
44
from unittest import TestCase
55

6-
from lndmanage.lib import openchannels
7-
86
from test.testing_common import (
97
test_graphs_paths,
108
TestNetwork,
119
)
1210

11+
from lndmanage.lib import openchannels
12+
1313

1414
def confirm_transactions(testnet):
1515
for _ in range(6):

test/test_rebalance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import time
44
from typing import Optional
55

6-
from lndmanage.lib.rebalance import Rebalancer
7-
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
8-
from lndmanage.lib.exceptions import NoRebalanceCandidates
9-
106
from test.testing_common import (
117
test_graphs_paths,
128
SLEEP_SEC_AFTER_REBALANCING,
139
TestNetwork
1410
)
1511

12+
from lndmanage.lib.rebalance import Rebalancer
13+
from lndmanage.lib.ln_utilities import local_balance_to_unbalancedness
14+
from lndmanage.lib.exceptions import NoRebalanceCandidates
15+
1616

1717
class RebalanceTest(TestNetwork):
1818
"""

test/testing_common.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
import shutil
44
from unittest import TestCase
55

6+
# testing base folder
7+
test_dir = os.path.dirname(os.path.realpath(__file__))
8+
bin_dir = os.path.join(test_dir, 'bin')
9+
graph_definitions_dir = os.path.join(test_dir, 'graph_definitions')
10+
test_data_dir = os.path.join(test_dir, 'test_data')
11+
12+
# set lndmanage_home path to be in the test_data folder and make sure the
13+
# directory exists
14+
lndmanage_home = os.path.join(test_data_dir, 'lndmanage')
15+
os.makedirs(lndmanage_home, exist_ok=True)
16+
17+
# create empty config and set env var to not trigger error when importing settings
18+
open(os.path.join(lndmanage_home, 'config.ini'), 'a').close()
19+
os.environ.setdefault('LNDMANAGE_HOME', lndmanage_home)
20+
621
from lnregtest.lib.network import Network
722

823
from lndmanage.lib.node import LndNode
@@ -17,17 +32,6 @@
1732
# constants for testing
1833
SLEEP_SEC_AFTER_REBALANCING = 2
1934

20-
# testing base folder
21-
test_dir = os.path.dirname(os.path.realpath(__file__))
22-
bin_dir = os.path.join(test_dir, 'bin')
23-
graph_definitions_dir = os.path.join(test_dir, 'graph_definitions')
24-
test_data_dir = os.path.join(test_dir, 'test_data')
25-
26-
# set lndmanage_home path to be in the test_data folder and make sure the
27-
# folder exists
28-
lndmanage_home = os.path.join(test_data_dir, 'lndmanage')
29-
os.makedirs(lndmanage_home, exist_ok=True)
30-
3135
test_graphs_paths = {
3236
'star_ring_3_liquid': os.path.join(
3337
graph_definitions_dir, 'star_ring_3_liquid.py'),

0 commit comments

Comments
 (0)