aboutsummaryrefslogtreecommitdiff
path: root/test/functional/interface_rest.py
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2018-10-16 22:38:56 +0000
committerRoss Nicoll <[email protected]>2019-07-13 22:25:22 +0000
commitce564e381aba126dbfc33a26184a4b8e1e3b077c (patch)
tree2c90cbd5ff474dd4e86ed02ed9c7a70e7c7684f0 /test/functional/interface_rest.py
parentUpdate dependency builder and its packages to be ready for Dogecoin specifics (diff)
downloaddiscoin-ce564e381aba126dbfc33a26184a4b8e1e3b077c.tar.xz
discoin-ce564e381aba126dbfc33a26184a4b8e1e3b077c.zip
Merge AuxPoW support from Namecore
Changes are as below: Wrap CBlockHeader::nVersion into a new class (CBlockVersion). This allows to take care of interpreting the field into a base version, auxpow flag and the chain ID. Update getauxblock.py for new 'generate' RPC call. Add 'auxpow' to block JSON. Accept auxpow as PoW verification. Add unit tests for auxpow verification. Add check for memory-layout of CBlockVersion. Weaken auxpow chain ID checks for the testnet. Allow Params() to overrule when to check the auxpow chain ID and for legacy blocks. Use this to disable the checks on testnet. Introduce CPureBlockHeader. Split the block header part that is used by auxpow and the "real" block header (that uses auxpow) to resolve the cyclic dependency between the two. Differentiate between uint256 and arith_uint256. This change was done upstream, modify the auxpow code. Add missing lock in auxpow_tests. Fix REST header check for auxpow headers. Those can be longer, thus take that into account. Also perform the check actually on an auxpow header. Correctly set the coinbase for getauxblock results. Call IncrementExtraNonce in getauxblock so that the coinbase is actually initialised with the stuff it should be. (BIP30 block height and COINBASE_FLAGS.) Implement getauxblock plus regression test. Turn auxpow test into FIXTURE test. This allows using of the Params() calls. Move CMerkleTx code to auxpow.cpp. Otherwise we get linker errors when building without wallet. Fix rebase with BIP66. Update the code to handle BIP66's nVersion=3. Enforce that auxpow parent blocks have no auxpow block version. This is for compatibility with namecoind. See also https://github.com/namecoin/namecoin/pull/199. Move auxpow-related parameters to Consensus::Params.
Diffstat (limited to 'test/functional/interface_rest.py')
-rwxr-xr-xtest/functional/interface_rest.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
index afa9de580..2ae7b7c94 100755
--- a/test/functional/interface_rest.py
+++ b/test/functional/interface_rest.py
@@ -14,6 +14,7 @@ from struct import pack, unpack
import http.client
import urllib.parse
+from test_framework import auxpow
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@@ -175,7 +176,13 @@ class RESTTest (BitcoinTestFramework):
assert_equal(len(json_obj['utxos']), 0)
self.nodes[0].generate(1)
+
+ json_request = json_request.rstrip("/")
+ response = http_post_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True)
+ assert_equal(response.status, 200) #must be a 200 because we are within the limits
+
self.sync_all()
+ bb_hash = self.nodes[0].getbestblockhash()
json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
assert_equal(len(json_obj['utxos']), 1)
@@ -195,7 +202,7 @@ class RESTTest (BitcoinTestFramework):
long_uri = '/'.join(['{}-{}'.format(txid, n_) for n_ in range(15)])
self.test_rest_request("/getutxos/checkmempool/{}".format(long_uri), http_method='POST', status=200)
- self.nodes[0].generate(1) # generate block to not affect upcoming tests
+ mineAuxpowBlock(self.nodes[0]) # generate block to not affect upcoming tests
self.sync_all()
self.log.info("Test the /block and /headers URIs")
@@ -208,9 +215,10 @@ class RESTTest (BitcoinTestFramework):
# 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)
+ headerLen = int(response_header.getheader('content-length'))
+ assert_greater_than(headerLen, 80)
response_header_bytes = response_header.read()
- assert_equal(response_bytes[:80], response_header_bytes)
+ assert_equal(response_bytes[:headerLen], 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)
@@ -221,8 +229,10 @@ class RESTTest (BitcoinTestFramework):
# 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)
+ response_header_hex_bytes = response_header_hex.read().strip()
+ headerLen = len (response_header_hex_bytes)
+ assert_equal(binascii.hexlify(response_bytes[:headerLen]), response_header_hex_bytes)
+ assert_equal(encode(response_header_bytes, "hex_codec"), response_header_hex_bytes)
# Check json format
block_json_obj = self.test_rest_request("/block/{}".format(bb_hash))