Skip to content

Commit 08cb3e4

Browse files
committed
lint
1 parent 1085974 commit 08cb3e4

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

resources/scenarios/ln_framework/ln.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,8 @@ def channel(self, pk, capacity, push_amt, fee_rate):
380380
res = json.loads(response)
381381
if "result" not in res:
382382
raise Exception(res)
383-
res["txid"] = self.b64_to_hex(
384-
res["result"]["chan_pending"]["txid"], reverse=True
385-
)
386-
res["outpoint"] = (
387-
f"{res['txid']}:{res['result']['chan_pending']['output_index']}"
388-
)
383+
res["txid"] = self.b64_to_hex(res["result"]["chan_pending"]["txid"], reverse=True)
384+
res["outpoint"] = f"{res['txid']}:{res['result']['chan_pending']['output_index']}"
389385
return res
390386

391387
def update(self, txid_hex: str, policy: dict, capacity: int):

resources/scenarios/ln_init.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
from commander import Commander
77
from ln_framework.ln import (
8-
Policy,
98
CHANNEL_OPEN_START_HEIGHT,
109
CHANNEL_OPENS_PER_BLOCK,
10+
FEE_RATE_DECREMENT,
1111
MAX_FEE_RATE,
12-
FEE_RATE_DECREMENT
12+
Policy,
1313
)
14+
from test_framework.address import address_to_scriptpubkey
1415
from test_framework.messages import (
1516
COIN,
1617
CTransaction,
1718
CTxOut,
1819
)
19-
from test_framework.address import address_to_scriptpubkey
2020

2121

2222
class LNInit(Commander):
@@ -105,7 +105,7 @@ def get_ln_addr(self, ln):
105105
sat_amt = 10 * COIN
106106
helicopter.vout.append(CTxOut(sat_amt, address_to_scriptpubkey(addr)))
107107
rawtx = miner.fundrawtransaction(helicopter.serialize().hex())
108-
signed_tx = miner.signrawtransactionwithwallet(rawtx['hex'])['hex']
108+
signed_tx = miner.signrawtransactionwithwallet(rawtx["hex"])["hex"]
109109
txid = miner.sendrawtransaction(signed_tx)
110110
# confirm funds in last block before channel opens
111111
gen(1)
@@ -133,11 +133,14 @@ def confirm_ln_balance(self, ln_name):
133133
self.log.info(f"Got 0 balance from {ln_name} retrying in 5 seconds...")
134134
sleep(5)
135135
except Exception as e:
136-
self.log.info(f"Couldn't get balance from {ln_name} because {e}, retrying in 5 seconds...")
136+
self.log.info(
137+
f"Couldn't get balance from {ln_name} because {e}, retrying in 5 seconds..."
138+
)
137139
sleep(5)
138140

139141
fund_threads = [
140-
threading.Thread(target=confirm_ln_balance, args=(self, ln_name)) for ln_name in channel_openers
142+
threading.Thread(target=confirm_ln_balance, args=(self, ln_name))
143+
for ln_name in channel_openers
141144
]
142145
for thread in fund_threads:
143146
thread.start()
@@ -159,7 +162,9 @@ def get_ln_uri(self, ln):
159162
self.log.info(f"LN node {ln.name} has URI {uri}")
160163
break
161164
except Exception as e:
162-
self.log.info(f"Couldn't get URI from {ln.name} because {e}, retrying in 5 seconds...")
165+
self.log.info(
166+
f"Couldn't get URI from {ln.name} because {e}, retrying in 5 seconds..."
167+
)
163168
sleep(5)
164169

165170
uri_threads = [
@@ -212,7 +217,9 @@ def connect_ln(self, pair):
212217
else:
213218
raise Exception(res)
214219
except Exception as e:
215-
self.log.info(f"Couldn't connect {pair[0].name} -> {pair[1].name} because {e}, retrying in 5 seconds...")
220+
self.log.info(
221+
f"Couldn't connect {pair[0].name} -> {pair[1].name} because {e}, retrying in 5 seconds..."
222+
)
216223
sleep(5)
217224

218225
p2p_threads = [
@@ -268,15 +275,21 @@ def open_channel(self, ch, fee_rate):
268275
)
269276
ch["txid"] = res["txid"]
270277
ch["outpoint"] = res["outpoint"]
271-
self.log.info(f"Channel open success:\n{log}\n outpoint: {res['outpoint']}")
278+
self.log.info(
279+
f"Channel open success:\n{log}\n outpoint: {res['outpoint']}"
280+
)
272281
break
273282
except Exception as e:
274-
self.log.info(f"Couldn't open channel:\n{log}\n {e}\n Retrying in 5 seconds...")
283+
self.log.info(
284+
f"Couldn't open channel:\n{log}\n {e}\n Retrying in 5 seconds..."
285+
)
275286
sleep(5)
276287

277288
channels = sorted(ch_by_block[target_block], key=lambda ch: ch["id"]["index"])
278289
if len(channels) > CHANNEL_OPENS_PER_BLOCK:
279-
raise Exception(f"Too many channels in block {target_block}: {len(channels)} / Maximum: {CHANNEL_OPENS_PER_BLOCK}")
290+
raise Exception(
291+
f"Too many channels in block {target_block}: {len(channels)} / Maximum: {CHANNEL_OPENS_PER_BLOCK}"
292+
)
280293
index = 0
281294
fee_rate = MAX_FEE_RATE
282295
ch_threads = []
@@ -335,7 +348,9 @@ def ln_all_chs(self, ln):
335348
)
336349
sleep(5)
337350
except Exception as e:
338-
self.log.info(f"Couldn't check graph from {ln.name} because {e}, retrying in 5 seconds...")
351+
self.log.info(
352+
f"Couldn't check graph from {ln.name} because {e}, retrying in 5 seconds..."
353+
)
339354
sleep(5)
340355

341356
ch_ann_threads = [
@@ -367,7 +382,9 @@ def update_policy(self, ln, txid_hex, policy, capacity):
367382
continue
368383
break
369384
except Exception as e:
370-
self.log.info(f"Couldn't update channel policy for {ln.name} because {e}, retrying in 5 seconds...")
385+
self.log.info(
386+
f"Couldn't update channel policy for {ln.name} because {e}, retrying in 5 seconds..."
387+
)
371388
sleep(5)
372389

373390
update_threads = []
@@ -416,7 +433,9 @@ def matching_graph(self, expected, ln):
416433
try:
417434
actual = ln.graph()["edges"]
418435
except Exception as e:
419-
self.log.info(f"Couldn't get graph from {ln.name} because {e}, retrying in 5 seconds...")
436+
self.log.info(
437+
f"Couldn't get graph from {ln.name} because {e}, retrying in 5 seconds..."
438+
)
420439
sleep(5)
421440
continue
422441

src/warnet/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from rich.table import Table
1313

1414
from resources.scenarios.ln_framework.ln import (
15-
Policy,
1615
CHANNEL_OPEN_START_HEIGHT,
17-
CHANNEL_OPENS_PER_BLOCK
16+
CHANNEL_OPENS_PER_BLOCK,
17+
Policy,
1818
)
1919

2020
from .constants import (

test/ln_basic_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def fund_wallets(self):
5858
addr = json.loads(self.warnet(f"ln rpc {ln} newaddress p2wkh"))["address"]
5959
self.warnet(f"bitcoin rpc tank-0000 sendtoaddress {addr} 10")
6060
self.wait_for_predicate(
61-
lambda: json.loads(self.warnet("bitcoin rpc tank-0000 getmempoolinfo"))["size"] == len(self.lns)
61+
lambda: json.loads(self.warnet("bitcoin rpc tank-0000 getmempoolinfo"))["size"]
62+
== len(self.lns)
6263
)
6364
self.warnet("bitcoin rpc tank-0000 -generate 1")
6465

0 commit comments

Comments
 (0)