Skip to content

Commit e88a626

Browse files
committed
update tests
1 parent f6ab5ed commit e88a626

File tree

2 files changed

+21
-51
lines changed

2 files changed

+21
-51
lines changed

test/ln_test.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from test_base import TestBase
88

99
from warnet.cli.process import run_command
10+
from warnet.k8s import get_pods_with_label
1011

1112

1213
class LNTest(TestBase):
@@ -102,18 +103,24 @@ def test_ln_payment_2_to_0(self):
102103
payment["fee_msat"] == "2213"
103104
), f"Expected fee_msat to be 2213, got {payment['fee_msat']}"
104105

105-
# def test_simln(self):
106-
# self.log.info("Engaging simln")
107-
# node2pub, _ = json.loads(self.warnet("ln rpc 2 getinfo"))["uris"][0].split("@")
108-
# activity = [
109-
# {"source": "ln-0", "destination": node2pub, "interval_secs": 1, "amount_msat": 2000}
110-
# ]
111-
# self.warnet(
112-
# f"network export --exclude=[1] --activity={json.dumps(activity).replace(' ', '')}"
113-
# )
114-
# self.wait_for_predicate(lambda: self.check_invoices(2) > 1)
115-
# assert self.check_invoices(0) == 1, "Expected one invoice for node 0"
116-
# assert self.check_invoices(1) == 0, "Expected no invoices for node 1"
106+
def test_simln(self):
107+
self.log.info("Engaging simln")
108+
pods = get_pods_with_label("mission=lightning")
109+
node2pub = self.warnet(f"ln pubkey {pods[1].metadata.name}")
110+
activity = [
111+
{
112+
"source": pods[0].metadata.name,
113+
"destination": node2pub,
114+
"interval_secs": 1,
115+
"amount_msat": 2000,
116+
}
117+
]
118+
self.warnet(
119+
f"network export --exclude=[1] --activity={json.dumps(activity).replace(' ', '')}"
120+
)
121+
self.wait_for_predicate(lambda: self.check_invoices(2) > 1)
122+
assert self.check_invoices(0) == 1, "Expected one invoice for node 0"
123+
assert self.check_invoices(1) == 0, "Expected no invoices for node 1"
117124

118125
def check_invoice_settled(self):
119126
invs = json.loads(self.warnet("ln rpc tank-0002-ln listinvoices"))["invoices"]

test/simln_test.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
from time import sleep
66

77
import pexpect
8-
from kubernetes.stream import stream
98
from test_base import TestBase
109

11-
from warnet.k8s import get_pods_with_label, get_static_client
10+
from warnet.k8s import get_pods_with_label
1211
from warnet.process import run_command
1312

1413

@@ -47,45 +46,9 @@ def check_simln_logs(self):
4746
def copy_results(self) -> bool:
4847
self.log.info("Copying results")
4948
sleep(20)
50-
pod = get_pods_with_label("mission=plugin")[0]
51-
v1 = get_static_client()
49+
get_pods_with_label("mission=plugin")[0]
5250

53-
source_path = "/config/results"
5451
destination_path = "results"
55-
os.makedirs(destination_path, exist_ok=True)
56-
command = ["tar", "cf", "-", source_path]
57-
58-
# Create the stream
59-
resp = stream(
60-
v1.connect_get_namespaced_pod_exec,
61-
name=pod.metadata.name,
62-
namespace=pod.metadata.namespace,
63-
command=command,
64-
stderr=True,
65-
stdin=False,
66-
stdout=True,
67-
tty=False,
68-
_preload_content=False,
69-
)
70-
71-
# Write the tar output to a file
72-
tar_file = os.path.join(destination_path, "results.tar")
73-
with open(tar_file, "wb") as f:
74-
while resp.is_open():
75-
resp.update(timeout=1)
76-
if resp.peek_stdout():
77-
f.write(resp.read_stdout().encode("utf-8"))
78-
if resp.peek_stderr():
79-
print(resp.read_stderr())
80-
81-
resp.close()
82-
83-
import tarfile
84-
85-
with tarfile.open(tar_file, "r") as tar:
86-
tar.extractall(path=destination_path)
87-
88-
os.remove(tar_file)
8952

9053
for root, _dirs, files in os.walk(destination_path):
9154
for file_name in files:

0 commit comments

Comments
 (0)