7
7
from pathlib import Path
8
8
9
9
from test_base import TestBase
10
- from warnet .lnd import LNDNode
10
+
11
+ # from warnet.lnd import LNDNode
11
12
from warnet .utils import DEFAULT_TAG
12
13
13
14
@@ -24,20 +25,19 @@ def __init__(self):
24
25
def run_test (self ):
25
26
self .test_graph_creation_and_import ()
26
27
self .validate_graph_schema ()
27
-
28
- self .start_server ()
29
28
try :
30
- self .test_graph_with_optional_services ()
29
+ # TODO: re-enable these when we add lightning back
30
+ # self.test_graph_with_optional_services()
31
31
self .test_created_graph ()
32
- self .test_imported_graph ()
32
+ # self.test_imported_graph()
33
33
finally :
34
34
self .stop_server ()
35
35
36
36
def test_graph_creation_and_import (self ):
37
37
self .log .info (f"CLI tool creating test graph file: { self .tf_create } " )
38
38
self .log .info (
39
39
self .warcli (
40
- f"graph create 10 --outfile={ self .tf_create } --version={ DEFAULT_TAG } " , network = False
40
+ f"graph create 10 --outfile={ self .tf_create } --version={ DEFAULT_TAG } "
41
41
)
42
42
)
43
43
self .wait_for_predicate (lambda : Path (self .tf_create ).exists ())
@@ -46,16 +46,15 @@ def test_graph_creation_and_import(self):
46
46
self .log .info (
47
47
self .warcli (
48
48
f"graph import-json { self .json_file_path } --outfile={ self .tf_import } --ln_image=carlakirkcohen/lnd:attackathon --cb=carlakirkcohen/circuitbreaker:attackathon-test" ,
49
- network = False ,
50
49
)
51
50
)
52
51
self .wait_for_predicate (lambda : Path (self .tf_import ).exists ())
53
52
54
53
def validate_graph_schema (self ):
55
54
self .log .info ("Validating graph schema" )
56
- assert "invalid" not in self .warcli (f"graph validate { Path (self .tf_create )} " , False )
57
- assert "invalid" not in self .warcli (f"graph validate { Path (self .tf_import )} " , False )
58
- assert "invalid" not in self .warcli (f"graph validate { self .graph_file_path } " , False )
55
+ assert "invalid" not in self .warcli (f"graph validate { Path (self .tf_create )} " )
56
+ assert "invalid" not in self .warcli (f"graph validate { Path (self .tf_import )} " )
57
+ assert "invalid" not in self .warcli (f"graph validate { self .graph_file_path } " )
59
58
60
59
def test_graph_with_optional_services (self ):
61
60
self .log .info ("Testing graph with optional services..." )
@@ -70,7 +69,7 @@ def test_graph_with_optional_services(self):
70
69
71
70
def test_created_graph (self ):
72
71
self .log .info ("Testing created graph..." )
73
- self .log .info (self .warcli (f"network start { Path (self .tf_create )} --force " ))
72
+ self .log .info (self .warcli (f"network start { Path (self .tf_create )} " ))
74
73
self .wait_for_all_tanks_status (target = "running" )
75
74
self .wait_for_all_edges ()
76
75
self .warcli ("bitcoin rpc 0 getblockcount" )
@@ -79,7 +78,7 @@ def test_created_graph(self):
79
78
80
79
def test_imported_graph (self ):
81
80
self .log .info ("Testing imported graph..." )
82
- self .log .info (self .warcli (f"network start { Path (self .tf_import )} --force " ))
81
+ self .log .info (self .warcli (f"network start { Path (self .tf_import )} " ))
83
82
self .wait_for_all_tanks_status (target = "running" )
84
83
self .wait_for_all_edges ()
85
84
self .warcli ("bitcoin rpc 0 getblockcount" )
@@ -90,23 +89,23 @@ def test_imported_graph(self):
90
89
91
90
def verify_ln_channel_policies (self ):
92
91
self .log .info ("Ensuring warnet LN channel policies match imported JSON description" )
93
- with open (self .json_file_path ) as file :
94
- actual = json .loads (self .warcli ("ln rpc 0 describegraph" ))["edges" ]
95
- expected = json .loads (file .read ())["edges" ]
96
- expected = sorted (expected , key = lambda chan : int (chan ["channel_id" ]))
97
- for chan_index , actual_chan_json in enumerate (actual ):
98
- expected_chan = LNDNode .lnchannel_from_json (expected [chan_index ])
99
- actual_chan = LNDNode .lnchannel_from_json (actual_chan_json )
100
- if not expected_chan .channel_match (actual_chan ):
101
- self .log .info (
102
- f"Channel { chan_index } policy mismatch, testing flipped channel: { actual_chan .short_chan_id } "
103
- )
104
- if not expected_chan .channel_match (actual_chan .flip ()):
105
- raise Exception (
106
- f"Channel policy doesn't match source: { actual_chan .short_chan_id } \n "
107
- + f"Actual:\n { actual_chan } \n "
108
- + f"Expected:\n { expected_chan } \n "
109
- )
92
+ # with open(self.json_file_path) as file:
93
+ # actual = json.loads(self.warcli("ln rpc 0 describegraph"))["edges"]
94
+ # expected = json.loads(file.read())["edges"]
95
+ # expected = sorted(expected, key=lambda chan: int(chan["channel_id"]))
96
+ # for chan_index, actual_chan_json in enumerate(actual):
97
+ # expected_chan = LNDNode.lnchannel_from_json(expected[chan_index])
98
+ # actual_chan = LNDNode.lnchannel_from_json(actual_chan_json)
99
+ # if not expected_chan.channel_match(actual_chan):
100
+ # self.log.info(
101
+ # f"Channel {chan_index} policy mismatch, testing flipped channel: {actual_chan.short_chan_id}"
102
+ # )
103
+ # if not expected_chan.channel_match(actual_chan.flip()):
104
+ # raise Exception(
105
+ # f"Channel policy doesn't match source: {actual_chan.short_chan_id}\n"
106
+ # + f"Actual:\n{actual_chan}\n"
107
+ # + f"Expected:\n{expected_chan}\n"
108
+ # )
110
109
111
110
112
111
if __name__ == "__main__" :
0 commit comments