aboutsummaryrefslogtreecommitdiff
path: root/contrib/testgen
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2018-04-16 11:13:07 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2018-04-16 17:25:11 +0200
commitf020aca297e8a6c9f7b6a6e08e583847d37edace (patch)
treeb7573c8faefcf5c92d21f1bd297fc72a8da3393f /contrib/testgen
parent0d6992168c2bda85b18fda8f6dea08da433a0dc9 (diff)
Minor Python cleanups to make flake8 pass with the new rules enabled
Diffstat (limited to 'contrib/testgen')
-rw-r--r--contrib/testgen/base58.py9
-rwxr-xr-xcontrib/testgen/gen_base58_test_vectors.py9
2 files changed, 11 insertions, 7 deletions
diff --git a/contrib/testgen/base58.py b/contrib/testgen/base58.py
index 0dbb79a707..071bc722b0 100644
--- a/contrib/testgen/base58.py
+++ b/contrib/testgen/base58.py
@@ -43,8 +43,10 @@ def b58encode(v):
# leading 0-bytes in the input become leading-1s
nPad = 0
for c in v:
- if c == 0: nPad += 1
- else: break
+ if c == 0:
+ nPad += 1
+ else:
+ break
return (__b58chars[0]*nPad) + result
@@ -98,7 +100,8 @@ def b58decode_chk(v):
def get_bcaddress_version(strAddress):
""" Returns None if strAddress is invalid. Otherwise returns integer version of address. """
addr = b58decode_chk(strAddress)
- if addr is None or len(addr)!=21: return None
+ if addr is None or len(addr)!=21:
+ return None
version = addr[0]
return ord(version)
diff --git a/contrib/testgen/gen_base58_test_vectors.py b/contrib/testgen/gen_base58_test_vectors.py
index 4351605786..de15657d27 100755
--- a/contrib/testgen/gen_base58_test_vectors.py
+++ b/contrib/testgen/gen_base58_test_vectors.py
@@ -74,12 +74,12 @@ def gen_invalid_vector(template, corrupt_prefix, randomize_payload_size, corrupt
prefix = os.urandom(1)
else:
prefix = bytearray(template[0])
-
+
if randomize_payload_size:
payload = os.urandom(max(int(random.expovariate(0.5)), 50))
else:
payload = os.urandom(template[1])
-
+
if corrupt_suffix:
suffix = os.urandom(len(template[2]))
else:
@@ -114,7 +114,8 @@ def gen_invalid_vectors():
yield val,
if __name__ == '__main__':
- import sys, json
+ import sys
+ import json
iters = {'valid':gen_valid_vectors, 'invalid':gen_invalid_vectors}
try:
uiter = iters[sys.argv[1]]
@@ -124,7 +125,7 @@ if __name__ == '__main__':
count = int(sys.argv[2])
except IndexError:
count = 0
-
+
data = list(islice(uiter(), count))
json.dump(data, sys.stdout, sort_keys=True, indent=4)
sys.stdout.write('\n')