Skip to content

Commit e9a4632

Browse files
committed
lint
1 parent 259df04 commit e9a4632

File tree

4 files changed

+94
-68
lines changed

4 files changed

+94
-68
lines changed

src/warnet/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class AnnexMember(Enum):
4848

4949
PLUGIN_ANNEX = "annex"
5050

51-
DEFAULT_IMAGE_REPO="bitcoindevproject/bitcoin"
51+
DEFAULT_IMAGE_REPO = "bitcoindevproject/bitcoin"
5252

5353
# Bitcoin Core config
54-
FORK_OBSERVER_RPCAUTH="forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c"
54+
FORK_OBSERVER_RPCAUTH = "forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c"
5555
# Fork Observer config
56-
FORK_OBSERVER_RPC_USER="forkobserver"
57-
FORK_OBSERVER_RPC_PASSWORD="tabconf2024"
56+
FORK_OBSERVER_RPC_USER = "forkobserver"
57+
FORK_OBSERVER_RPC_PASSWORD = "tabconf2024"
5858

5959
# Directories and files for non-python assets, e.g., helm charts, example scenarios, default configs
6060
SRC_DIR = files("warnet")

src/warnet/deploy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
DEFAULTS_FILE,
1616
DEFAULTS_NAMESPACE_FILE,
1717
FORK_OBSERVER_CHART,
18+
FORK_OBSERVER_RPC_PASSWORD,
19+
FORK_OBSERVER_RPC_USER,
1820
HELM_COMMAND,
1921
INGRESS_HELM_COMMANDS,
2022
LOGGING_CRD_COMMANDS,
@@ -29,8 +31,6 @@
2931
AnnexMember,
3032
HookValue,
3133
WarnetContent,
32-
FORK_OBSERVER_RPC_USER,
33-
FORK_OBSERVER_RPC_PASSWORD,
3434
)
3535
from .control import _logs, _run
3636
from .k8s import (

src/warnet/graph.py

Lines changed: 87 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44
import sys
55
from pathlib import Path
66

7-
from rich import print
8-
from rich.console import Console
9-
from rich.table import Table
10-
117
import click
128
import inquirer
139
import yaml
10+
from rich import print
11+
from rich.console import Console
12+
from rich.table import Table
1413

1514
from resources.scenarios.ln_framework.ln import Policy
1615

1716
from .constants import (
17+
DEFAULT_IMAGE_REPO,
1818
DEFAULT_TAG,
19-
SUPPORTED_TAGS,
2019
FORK_OBSERVER_RPCAUTH,
21-
DEFAULT_IMAGE_REPO,
20+
SUPPORTED_TAGS,
2221
)
2322

2423

@@ -49,7 +48,7 @@ def custom_graph(
4948
index = 0
5049

5150
for entry in tanks:
52-
for i in range(int(entry["count"])):
51+
for _ in range(int(entry["count"])):
5352
if ":" in entry["version"] and "/" in entry["version"]:
5453
repo, tag = entry["version"].split(":")
5554
image = {"repository": repo, "tag": tag}
@@ -98,11 +97,10 @@ def custom_graph(
9897
"repository": DEFAULT_IMAGE_REPO,
9998
"pullPolicy": "IfNotPresent",
10099
},
101-
"defaultConfig":
102-
f"rpcauth={FORK_OBSERVER_RPCAUTH}\n" +
103-
"rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n" +
104-
"rpcwhitelistdefault=0\n" +
105-
"debug=rpc\n"
100+
"defaultConfig": f"rpcauth={FORK_OBSERVER_RPCAUTH}\n"
101+
+ "rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n"
102+
+ "rpcwhitelistdefault=0\n"
103+
+ "debug=rpc\n",
106104
}
107105

108106
# Configure logging
@@ -118,12 +116,15 @@ def custom_graph(
118116

119117

120118
def inquirer_create_network(project_path: Path):
121-
network_name_prompt = inquirer.prompt([
122-
inquirer.Text(
123-
"network_name",
124-
message=click.style("Enter your network name", fg="blue", bold=True),
125-
validate=lambda _, x: len(x) > 0,
126-
)])
119+
network_name_prompt = inquirer.prompt(
120+
[
121+
inquirer.Text(
122+
"network_name",
123+
message=click.style("Enter your network name", fg="blue", bold=True),
124+
validate=lambda _, x: len(x) > 0,
125+
)
126+
]
127+
)
127128
if not network_name_prompt:
128129
click.secho("Setup cancelled by user.", fg="yellow")
129130
return False
@@ -140,81 +141,108 @@ def inquirer_create_network(project_path: Path):
140141

141142
Console().print(table)
142143

143-
add_more_prompt = inquirer.prompt([
144-
inquirer.List(
145-
"add_more",
146-
message=click.style(f"How many nodes to add? (0 = done)", fg="blue", bold=True),
147-
choices=["0", "4", "8", "12", "20", "50", "other"],
148-
default="12")])
144+
add_more_prompt = inquirer.prompt(
145+
[
146+
inquirer.List(
147+
"add_more",
148+
message=click.style("How many nodes to add? (0 = done)", fg="blue", bold=True),
149+
choices=["0", "4", "8", "12", "20", "50", "other"],
150+
default="12",
151+
)
152+
]
153+
)
149154
if not add_more_prompt:
150155
click.secho("Setup cancelled by user.", fg="yellow")
151156
return False
152157
if add_more_prompt["add_more"].startswith("0"):
153158
break
154159

155160
if add_more_prompt["add_more"] == "other":
156-
how_many_prompt = inquirer.prompt([
157-
inquirer.Text(
158-
"how_many",
159-
message=click.style("Enter the number of nodes", fg="blue", bold=True),
160-
validate=lambda _, x: int(x) > 0)])
161+
how_many_prompt = inquirer.prompt(
162+
[
163+
inquirer.Text(
164+
"how_many",
165+
message=click.style("Enter the number of nodes", fg="blue", bold=True),
166+
validate=lambda _, x: int(x) > 0,
167+
)
168+
]
169+
)
161170
if not how_many_prompt:
162171
click.secho("Setup cancelled by user.", fg="yellow")
163172
return False
164173
how_many = how_many_prompt["how_many"]
165174
else:
166175
how_many = add_more_prompt["add_more"]
167176

168-
tank_details_prompt = inquirer.prompt([
169-
inquirer.List(
170-
"version",
171-
message=click.style("Which version would you like to add to network?", fg="blue", bold=True),
172-
choices=["other"] + SUPPORTED_TAGS,
173-
default=DEFAULT_TAG,
177+
tank_details_prompt = inquirer.prompt(
178+
[
179+
inquirer.List(
180+
"version",
181+
message=click.style(
182+
"Which version would you like to add to network?", fg="blue", bold=True
183+
),
184+
choices=["other"] + SUPPORTED_TAGS,
185+
default=DEFAULT_TAG,
174186
),
175-
inquirer.List(
176-
"connections",
177-
message=click.style(
178-
"How many connections would you like each of these nodes to have?",
179-
fg="blue",
180-
bold=True,
187+
inquirer.List(
188+
"connections",
189+
message=click.style(
190+
"How many connections would you like each of these nodes to have?",
191+
fg="blue",
192+
bold=True,
193+
),
194+
choices=["0", "1", "2", "8", "12", "other"],
195+
default="8",
181196
),
182-
choices=["0", "1", "2", "8", "12", "other"],
183-
default="8",
184-
)])
197+
]
198+
)
185199
if not tank_details_prompt:
186200
click.secho("Setup cancelled by user.", fg="yellow")
187201
return False
188202
break
189203
if tank_details_prompt["version"] == "other":
190-
custom_version_prompt = inquirer.prompt([
191-
inquirer.Text(
192-
"version",
193-
message=click.style("Provide dockerhub repository/image:tag", fg="blue", bold=True),
194-
validate=lambda _, x: "/" in x and ":" in x)])
204+
custom_version_prompt = inquirer.prompt(
205+
[
206+
inquirer.Text(
207+
"version",
208+
message=click.style(
209+
"Provide dockerhub repository/image:tag", fg="blue", bold=True
210+
),
211+
validate=lambda _, x: "/" in x and ":" in x,
212+
)
213+
]
214+
)
195215
if not custom_version_prompt:
196216
click.secho("Setup cancelled by user.", fg="yellow")
197217
return False
198218
tank_details_prompt["version"] = custom_version_prompt["version"]
199219

200220
if tank_details_prompt["connections"] == "other":
201-
how_many_conn_prompt = inquirer.prompt([
202-
inquirer.Text(
203-
"how_many_conn",
204-
message=click.style("Enter the number of connections", fg="blue", bold=True),
205-
validate=lambda _, x: int(x) > 0)])
221+
how_many_conn_prompt = inquirer.prompt(
222+
[
223+
inquirer.Text(
224+
"how_many_conn",
225+
message=click.style(
226+
"Enter the number of connections", fg="blue", bold=True
227+
),
228+
validate=lambda _, x: int(x) > 0,
229+
)
230+
]
231+
)
206232
if not how_many_conn_prompt:
207233
click.secho("Setup cancelled by user.", fg="yellow")
208234
return False
209235
how_many_conn = how_many_conn_prompt["how_many_conn"]
210236
else:
211237
how_many_conn = tank_details_prompt["connections"]
212238

213-
tanks.append({
214-
"version": tank_details_prompt["version"],
215-
"count": how_many,
216-
"connections": how_many_conn
217-
})
239+
tanks.append(
240+
{
241+
"version": tank_details_prompt["version"],
242+
"count": how_many,
243+
"connections": how_many_conn,
244+
}
245+
)
218246

219247
fork_observer = click.prompt(
220248
click.style(

test/plugin_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
class PluginTest(TestBase):
1515
def __init__(self):
1616
super().__init__()
17-
self.network_dir = (
18-
Path(os.path.dirname(__file__)) / "data" / "network_with_plugins"
19-
)
17+
self.network_dir = Path(os.path.dirname(__file__)) / "data" / "network_with_plugins"
2018
self.plugins_dir = Path(os.path.dirname(__file__)).parent / "resources" / "plugins"
2119
self.simln_exec = self.plugins_dir / "simln" / "plugin.py"
2220

0 commit comments

Comments
 (0)