Browse Source

python: quieten modern flake8.

After Ubuntu 18.10 upgrade, lots of new flake8 warnings.

$ flake8 --version:
3.5.0 (mccabe: 0.6.1, pycodestyle: 2.4.0, pyflakes: 1.6.0) CPython 3.6.7rc1 on Linux

Note it seems that W503 warned about line breaks before binary
operators, and W504 complains about them after.  I prefer W504, so
disable W503.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
plugin-1
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
38e6aa66ff
  1. 3
      Makefile
  2. 16
      tests/test_closing.py
  3. 14
      tests/test_connection.py
  4. 14
      tests/test_gossip.py
  5. 14
      tests/test_misc.py
  6. 8
      tests/test_pay.py
  7. 6
      tests/utils.py

3
Makefile

@ -274,7 +274,8 @@ PYSRC=$(shell git ls-files "*.py") contrib/pylightning/lightning-pay
check-python:
@# E501 line too long (N > 79 characters)
@# E731 do not assign a lambda expression, use a def
@flake8 --ignore=E501,E731 --exclude=contrib/pylightning/lightning/__init__.py ${PYSRC}
@# W503: line break before binary operator
@flake8 --ignore=E501,E731,W503 --exclude=contrib/pylightning/lightning/__init__.py ${PYSRC}
check-includes:
@tools/check-includes.sh

16
tests/test_closing.py

@ -214,8 +214,8 @@ def test_closing_different_fees(node_factory, bitcoind, executor):
bitcoind.generate_block(6)
# Now wait for them all to hit normal state, do payments
l1.daemon.wait_for_logs(['update for channel .* now ACTIVE'] * num_peers +
['to CHANNELD_NORMAL'] * num_peers)
l1.daemon.wait_for_logs(['update for channel .* now ACTIVE'] * num_peers
+ ['to CHANNELD_NORMAL'] * num_peers)
for p in peers:
if p.amount != 0:
l1.pay(p, 100000000)
@ -1413,16 +1413,16 @@ def test_permfail(node_factory, bitcoind):
l2.daemon.wait_for_log(' to ONCHAIN')
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) after 5 blocks')
wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status'] ==
['ONCHAIN:Tracking their unilateral close',
'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel'])
wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status']
== ['ONCHAIN:Tracking their unilateral close',
'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel'])
def check_billboard():
billboard = only_one(l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'])['status']
return (
len(billboard) == 2 and
billboard[0] == 'ONCHAIN:Tracking our own unilateral close' and
re.fullmatch('ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1])
len(billboard) == 2
and billboard[0] == 'ONCHAIN:Tracking our own unilateral close'
and re.fullmatch(r'ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1])
)
wait_for(check_billboard)

14
tests/test_connection.py

@ -910,7 +910,7 @@ def test_update_fee_reconnect(node_factory, bitcoind):
l1.set_feerates((14000, 14000, 3750))
l1.daemon.wait_for_log('Setting REMOTE feerate to 14000')
l2.daemon.wait_for_log('Setting LOCAL feerate to 14000')
l1.daemon.wait_for_log('dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
# Wait for reconnect....
l1.daemon.wait_for_log('Applying feerate 14000 to LOCAL')
@ -1203,7 +1203,7 @@ def test_funder_feerate_reconnect(node_factory, bitcoind):
# create fee update, causing disconnect.
l1.set_feerates((15000, 7500, 3750))
l2.daemon.wait_for_log('dev_disconnect: \-WIRE_COMMITMENT_SIGNED')
l2.daemon.wait_for_log(r'dev_disconnect: \-WIRE_COMMITMENT_SIGNED')
# Wait until they reconnect.
l1.daemon.wait_for_log('Peer transient failure in CHANNELD_NORMAL')
@ -1220,7 +1220,7 @@ def test_dataloss_protection(node_factory, bitcoind):
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# l1 should send out WIRE_INIT (0010)
l1.daemon.wait_for_log("\[OUT\] 0010"
l1.daemon.wait_for_log(r"\[OUT\] 0010"
# gflen == 0
"0000"
# lflen == 1
@ -1237,7 +1237,7 @@ def test_dataloss_protection(node_factory, bitcoind):
l2.start()
# l1 should have sent WIRE_CHANNEL_REESTABLISH with option_data_loss_protect.
l1.daemon.wait_for_log("\[OUT\] 0088"
l1.daemon.wait_for_log(r"\[OUT\] 0088"
# channel_id
"[0-9a-f]{64}"
# next_local_commitment_number
@ -1255,13 +1255,13 @@ def test_dataloss_protection(node_factory, bitcoind):
# Make sure both sides consider it completely settled (has received both
# REVOKE_AND_ACK)
l1.daemon.wait_for_logs(["\[IN\] 0085"] * 2)
l2.daemon.wait_for_logs(["\[IN\] 0085"] * 2)
l1.daemon.wait_for_logs([r"\[IN\] 0085"] * 2)
l2.daemon.wait_for_logs([r"\[IN\] 0085"] * 2)
l2.restart()
# l1 should have sent WIRE_CHANNEL_REESTABLISH with option_data_loss_protect.
l1.daemon.wait_for_log("\[OUT\] 0088"
l1.daemon.wait_for_log(r"\[OUT\] 0088"
# channel_id
"[0-9a-f]{64}"
# next_local_commitment_number

14
tests/test_gossip.py

@ -666,19 +666,19 @@ def test_gossip_query_channel_range(node_factory, bitcoind):
num=65535)
l1.daemon.wait_for_log(
# WIRE_REPLY_CHANNEL_RANGE
r'\[IN\] 0108' +
r'\[IN\] 0108'
# chain_hash
'................................................................' +
+ '................................................................'
# first_blocknum
'00000000' +
+ '00000000'
# number_of_blocks
'0000ffff' +
+ '0000ffff'
# complete
'01' +
+ '01'
# length
'....' +
+ '....'
# encoding
'01'
+ '01'
)

14
tests/test_misc.py

@ -55,7 +55,7 @@ def test_names(node_factory):
for key, alias, color in configs:
n = node_factory.get_node()
assert n.daemon.is_in_log('public key {}, alias {}.* \(color #{}\)'
assert n.daemon.is_in_log(r'public key {}, alias {}.* \(color #{}\)'
.format(key, alias, color))
@ -145,7 +145,7 @@ def test_ping(node_factory):
# Test gossip pinging.
ping_tests(l1, l2)
if DEVELOPER:
l1.daemon.wait_for_log('Got pong 1000 bytes \({}\.\.\.\)'
l1.daemon.wait_for_log(r'Got pong 1000 bytes \({}\.\.\.\)'
.format(l2.info['version']), timeout=1)
l1.fund_channel(l2, 10**5)
@ -153,7 +153,7 @@ def test_ping(node_factory):
# channeld pinging
ping_tests(l1, l2)
if DEVELOPER:
l1.daemon.wait_for_log('Got pong 1000 bytes \({}\.\.\.\)'
l1.daemon.wait_for_log(r'Got pong 1000 bytes \({}\.\.\.\)'
.format(l2.info['version']))
@ -819,7 +819,7 @@ def test_htlc_send_timeout(node_factory, bitcoind):
timedout = False
while not timedout:
try:
l2.daemon.wait_for_log('channeld-{} chan #[0-9]*:\[IN\] 0101'.format(l3.info['id']), timeout=30)
l2.daemon.wait_for_log(r'channeld-{} chan #[0-9]*:\[IN\] 0101'.format(l3.info['id']), timeout=30)
except TimeoutError:
timedout = True
@ -836,9 +836,9 @@ def test_htlc_send_timeout(node_factory, bitcoind):
assert only_one(err.error['data']['failures'])['erring_channel'] == chanid2
# L2 should send ping, but never receive pong so never send commitment.
l2.daemon.wait_for_log('channeld.*:\[OUT\] 0012')
assert not l2.daemon.is_in_log('channeld.*:\[IN\] 0013')
assert not l2.daemon.is_in_log('channeld.*:\[OUT\] 0084')
l2.daemon.wait_for_log(r'channeld.*:\[OUT\] 0012')
assert not l2.daemon.is_in_log(r'channeld.*:\[IN\] 0013')
assert not l2.daemon.is_in_log(r'channeld.*:\[OUT\] 0084')
# L2 killed the channel with l3 because it was too slow.
l2.daemon.wait_for_log('channeld-{}.*Adding HTLC too slow: killing channel'.format(l3.info['id']))

8
tests/test_pay.py

@ -385,10 +385,10 @@ def test_sendpay(node_factory):
p1 = l1.rpc.getpeer(l2.info['id'], 'info')
p2 = l2.rpc.getpeer(l1.info['id'], 'info')
return (
only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000 - amt and
only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000 and
only_one(p2['channels'])['msatoshi_to_us'] == amt and
only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000
only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000 - amt
and only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000
and only_one(p2['channels'])['msatoshi_to_us'] == amt
and only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000
)
wait_for(check_balances)

6
tests/utils.py

@ -585,9 +585,9 @@ class LightningNode(object):
def wait_for_routes(self, channel_ids):
# Could happen in any order...
self.daemon.wait_for_logs(['Received channel_update for channel {}\\(0\\)'.format(c)
for c in channel_ids] +
['Received channel_update for channel {}\\(1\\)'.format(c)
for c in channel_ids])
for c in channel_ids]
+ ['Received channel_update for channel {}\\(1\\)'.format(c)
for c in channel_ids])
def pay(self, dst, amt, label=None):
if not label:

Loading…
Cancel
Save