aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-02-08 10:56:48 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-02-08 10:56:54 +0100
commitb401b093556f53023d1615f7cff3eb84807c6e8b (patch)
tree9e71a1954b135e22f3d5e2e635c20cd0642c332a /test
parentca85449f22cb909b9ca83861aa51fbf8f40a9070 (diff)
parent9913419cc9db5f8ce7afa0c3774468c330136064 (diff)
Merge #21107: test: remove type: comments in favour of actual annotations
9913419cc9db5f8ce7afa0c3774468c330136064 test: remove type: comments in favour of actual annotations (fanquake) Pull request description: Now that we require Python 3.6+, we should be using variable type annotations directly rather than `# type:` comments. Also takes care of the discarded value issue in p2p_message_capture.py. See: https://github.com/bitcoin/bitcoin/pull/19509/files#r571674446. ACKs for top commit: MarcoFalke: review ACK 9913419cc9db5f8ce7afa0c3774468c330136064 jnewbery: Code review ACK 9913419cc9db5f8ce7afa0c3774468c330136064 Tree-SHA512: 63aba5eef6c1320578f66cf8a6d85ac9dbab9d30b0d21e6e966be8216e63606de12321320c2958c67933bf68d10f2e76e9c43928e5989614cea34dde4187aad8
Diffstat (limited to 'test')
-rw-r--r--test/functional/data/invalid_txs.py2
-rwxr-xr-xtest/functional/p2p_message_capture.py6
-rw-r--r--test/functional/test_framework/script.py6
3 files changed, 7 insertions, 7 deletions
diff --git a/test/functional/data/invalid_txs.py b/test/functional/data/invalid_txs.py
index 6e72db1d96..fab921ef19 100644
--- a/test/functional/data/invalid_txs.py
+++ b/test/functional/data/invalid_txs.py
@@ -57,7 +57,7 @@ class BadTxTemplate:
__metaclass__ = abc.ABCMeta
# The expected error code given by bitcoind upon submission of the tx.
- reject_reason = "" # type: Optional[str]
+ reject_reason: Optional[str] = ""
# Only specified if it differs from mempool acceptance error.
block_reject_reason = ""
diff --git a/test/functional/p2p_message_capture.py b/test/functional/p2p_message_capture.py
index 113e26c425..080b2d93ad 100755
--- a/test/functional/p2p_message_capture.py
+++ b/test/functional/p2p_message_capture.py
@@ -42,14 +42,14 @@ def mini_parser(dat_file):
if not tmp_header_raw:
break
tmp_header = BytesIO(tmp_header_raw)
- int.from_bytes(tmp_header.read(TIME_SIZE), "little") # type: int
+ tmp_header.read(TIME_SIZE) # skip the timestamp field
raw_msgtype = tmp_header.read(MSGTYPE_SIZE)
- msgtype = raw_msgtype.split(b'\x00', 1)[0] # type: bytes
+ msgtype: bytes = raw_msgtype.split(b'\x00', 1)[0]
remainder = raw_msgtype.split(b'\x00', 1)[1]
assert(len(msgtype) > 0)
assert(msgtype in MESSAGEMAP)
assert(len(remainder) == 0 or not remainder.decode().isprintable())
- length = int.from_bytes(tmp_header.read(LENGTH_SIZE), "little") # type: int
+ length: int = int.from_bytes(tmp_header.read(LENGTH_SIZE), "little")
data = f_in.read(length)
assert_equal(len(data), length)
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index be0e9f24e2..c35533698c 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -29,8 +29,6 @@ MAX_SCRIPT_ELEMENT_SIZE = 520
LOCKTIME_THRESHOLD = 500000000
ANNEX_TAG = 0x50
-OPCODE_NAMES = {} # type: Dict[CScriptOp, str]
-
LEAF_VERSION_TAPSCRIPT = 0xc0
def hash160(s):
@@ -47,7 +45,6 @@ def bn2vch(v):
# Serialize to bytes
return encoded_v.to_bytes(n_bytes, 'little')
-_opcode_instances = [] # type: List[CScriptOp]
class CScriptOp(int):
"""A single script opcode"""
__slots__ = ()
@@ -111,6 +108,9 @@ class CScriptOp(int):
_opcode_instances.append(super().__new__(cls, n))
return _opcode_instances[n]
+OPCODE_NAMES: Dict[CScriptOp, str] = {}
+_opcode_instances: List[CScriptOp] = []
+
# Populate opcode instance table
for n in range(0xff + 1):
CScriptOp(n)