aboutsummaryrefslogtreecommitdiff
path: root/test/functional/interface_rest.py
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2019-01-23 10:44:13 -0500
committerGregory Sanders <gsanders87@gmail.com>2019-01-24 09:48:34 -0500
commit1e7f7417457a811f1e69a118df4c6e14033ddb55 (patch)
treeec7a74fa8417ca46c9301de550282f8c387f94bd /test/functional/interface_rest.py
parent82cf6813a4ef1b4a5439eb6cddb1ab426f3c31a2 (diff)
downloadbitcoin-1e7f7417457a811f1e69a118df4c6e14033ddb55.tar.xz
remove some magic mining constants in functional tests
Diffstat (limited to 'test/functional/interface_rest.py')
-rwxr-xr-xtest/functional/interface_rest.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
index d5a1b53408..9b1072b826 100755
--- a/test/functional/interface_rest.py
+++ b/test/functional/interface_rest.py
@@ -22,6 +22,8 @@ from test_framework.util import (
hex_str_to_bytes,
)
+from test_framework.messages import BLOCK_HEADER_SIZE
+
class ReqType(Enum):
JSON = 1
BIN = 2
@@ -213,26 +215,26 @@ class RESTTest (BitcoinTestFramework):
# Check binary format
response = self.test_rest_request("/block/{}".format(bb_hash), req_type=ReqType.BIN, ret_type=RetType.OBJ)
- assert_greater_than(int(response.getheader('content-length')), 80)
+ assert_greater_than(int(response.getheader('content-length')), BLOCK_HEADER_SIZE)
response_bytes = response.read()
# Compare with block header
response_header = self.test_rest_request("/headers/1/{}".format(bb_hash), req_type=ReqType.BIN, ret_type=RetType.OBJ)
- assert_equal(int(response_header.getheader('content-length')), 80)
+ assert_equal(int(response_header.getheader('content-length')), BLOCK_HEADER_SIZE)
response_header_bytes = response_header.read()
- assert_equal(response_bytes[:80], response_header_bytes)
+ assert_equal(response_bytes[:BLOCK_HEADER_SIZE], response_header_bytes)
# Check block hex format
response_hex = self.test_rest_request("/block/{}".format(bb_hash), req_type=ReqType.HEX, ret_type=RetType.OBJ)
- assert_greater_than(int(response_hex.getheader('content-length')), 160)
+ assert_greater_than(int(response_hex.getheader('content-length')), BLOCK_HEADER_SIZE*2)
response_hex_bytes = response_hex.read().strip(b'\n')
assert_equal(binascii.hexlify(response_bytes), response_hex_bytes)
# Compare with hex block header
response_header_hex = self.test_rest_request("/headers/1/{}".format(bb_hash), req_type=ReqType.HEX, ret_type=RetType.OBJ)
- assert_greater_than(int(response_header_hex.getheader('content-length')), 160)
- response_header_hex_bytes = response_header_hex.read(160)
- assert_equal(binascii.hexlify(response_bytes[:80]), response_header_hex_bytes)
+ assert_greater_than(int(response_header_hex.getheader('content-length')), BLOCK_HEADER_SIZE*2)
+ response_header_hex_bytes = response_header_hex.read(BLOCK_HEADER_SIZE*2)
+ assert_equal(binascii.hexlify(response_bytes[:BLOCK_HEADER_SIZE]), response_header_hex_bytes)
# Check json format
block_json_obj = self.test_rest_request("/block/{}".format(bb_hash))