forked from yukibtc/cln-ntfy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
42 lines (32 loc) · 995 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import logging
import os
import random
import string
from pathlib import Path
import pytest
RUST_PROFILE = os.environ.get("RUST_PROFILE", "debug")
COMPILED_PATH = Path.cwd() / "target" / RUST_PROFILE / "cln-ntfy"
DOWNLOAD_PATH = Path.cwd() / "tests" / "cln-ntfy"
@pytest.fixture
def get_plugin(directory):
if COMPILED_PATH.is_file():
return COMPILED_PATH
elif DOWNLOAD_PATH.is_file():
return DOWNLOAD_PATH
else:
raise ValueError("No files were found.")
def generate_random_label():
label_length = 8
random_label = "".join(
random.choice(string.ascii_letters) for _ in range(label_length)
)
return random_label
def generate_random_number():
return random.randint(1, 20_000_000_000_000_00_000)
def pay_with_thread(rpc, bolt11):
LOGGER = logging.getLogger(__name__)
try:
rpc.dev_pay(bolt11, dev_use_shadow=False)
except Exception as e:
LOGGER.debug(f"Error paying payment hash:{e}")
pass