aboutsummaryrefslogtreecommitdiff
path: root/test/functional/example_test.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-05-20 15:06:37 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-05-20 15:11:51 -0400
commit3eda7ea9ba724bfa53ad6f4f63af85fccb46da00 (patch)
tree8396830aefc33a70bf7e48f8b8aee81f895ebe04 /test/functional/example_test.py
parent448bdff26307981b7e32ba5610dad6674c1fe46d (diff)
parent4a614ff88ac71d6457513a4f7aa8a3235874ff3f (diff)
Merge #18764: refactor: test: replace inv type magic numbers by constants
4a614ff88ac71d6457513a4f7aa8a3235874ff3f test: explicit imports from test_framework.messages in p2p_invalid_messages.py (Sebastian Falbesoner) b35e1d2471c3d9e0b6cc4b94f4726a7e6ea32206 test: add inventory type constant MSG_CMPCT_BLOCK (Sebastian Falbesoner) eeaaa58d2ccc243a7506d34bca47c678867d6dd5 test: replace inv type magic numbers by constants (Sebastian Falbesoner) Pull request description: Many functional tests still use magic numbers for inventory types, either passed to the `CInv` constructor or for comparing the `type` member of `CInv`. This PR replaces all of those by constants in the module `test_framework.messages` that have been introduced in commit c32cf9f62285b5cd18a5064aee91f0802f0f87a8: `MSG_TX` (1) or `MSG_BLOCK` (2). It also introduces a new constant `MSG_CMPCT_BLOCK` (naming as in `src/protocol.h`) and uses it to replace the remaining magic numbers. The occurences of the magic numbers were identified through `grep`ing for `CInv(` and `type ==`. The idea was first to create a scripted-diff, but since also adding missing `import`s is needed, this would be non-trivial. Besides, also some unneeded comments like `# 2 == "Block"` could be removed. ACKs for top commit: gzhao408: ACK [`4a614ff`](https://github.com/bitcoin/bitcoin/pull/18764/commits/4a614ff88ac71d6457513a4f7aa8a3235874ff3f) Tree-SHA512: 4ba4fdef9f3eef7fd5ac72cb03ca3524863d1ae292161c550424a4c1047283fa2d2e7e03017d1fbae3652b3cb14f08b8d4b368403f3f209993aef3f2e2b22784
Diffstat (limited to 'test/functional/example_test.py')
-rwxr-xr-xtest/functional/example_test.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/functional/example_test.py b/test/functional/example_test.py
index 70dfe81d4e..5d782026dc 100755
--- a/test/functional/example_test.py
+++ b/test/functional/example_test.py
@@ -15,7 +15,7 @@ from collections import defaultdict
# Avoid wildcard * imports
from test_framework.blocktools import (create_block, create_coinbase)
-from test_framework.messages import CInv
+from test_framework.messages import CInv, MSG_BLOCK
from test_framework.mininode import (
P2PInterface,
mininode_lock,
@@ -198,7 +198,7 @@ class ExampleTest(BitcoinTestFramework):
getdata_request = msg_getdata()
for block in blocks:
- getdata_request.inv.append(CInv(2, block))
+ getdata_request.inv.append(CInv(MSG_BLOCK, block))
self.nodes[2].p2p.send_message(getdata_request)
# wait_until() will loop until a predicate condition is met. Use it to test properties of the