Created
December 4, 2016 22:29
-
-
Save ftrader/b94b6374fa034e9c28a682b88c1b68d7 to your computer and use it in GitHub Desktop.
sample nbits fix for invalidtxrequest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/qa/rpc-tests/invalidtxrequest.py b/qa/rpc-tests/invalidtxrequest.py | |
| index 26ca2f6..9fe6db4 100755 | |
| --- a/qa/rpc-tests/invalidtxrequest.py | |
| +++ b/qa/rpc-tests/invalidtxrequest.py | |
| @@ -15,6 +15,8 @@ import time | |
| In this test we connect to one node over p2p, and test tx requests. | |
| ''' | |
| +FORKHEIGHT=100 # to analyse fork interference | |
| + | |
| # Use the ComparisonTestFramework with 1 node: only use --testbinary. | |
| class InvalidTxRequestTest(ComparisonTestFramework): | |
| @@ -29,7 +31,7 @@ class InvalidTxRequestTest(ComparisonTestFramework): | |
| # for now, set the forkheight to workaround this interference. | |
| def setup_network(self): | |
| self.nodes = start_nodes(1, self.options.tmpdir, | |
| - extra_args=[['-debug', '-whitelist=127.0.0.1', ]], | |
| + extra_args=[['-forkheight=%s' % FORKHEIGHT, '-debug', '-whitelist=127.0.0.1', ]], | |
| binary=[self.options.testbinary]) | |
| # MVF-Core end | |
| @@ -64,7 +66,8 @@ class InvalidTxRequestTest(ComparisonTestFramework): | |
| ''' | |
| test = TestInstance(sync_every_block=False) | |
| for i in xrange(100): | |
| - block = create_block(self.tip, create_coinbase(height), self.block_time) | |
| + nbits = 0x207eeeee if i == (FORKHEIGHT-1) else 0x207fffff | |
| + block = create_block(self.tip, create_coinbase(height), self.block_time, nbits) | |
| block.solve() | |
| self.tip = block.sha256 | |
| self.block_time += 1 | |
| diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py | |
| index 88f553a..ef8b54d 100644 | |
| --- a/qa/rpc-tests/test_framework/blocktools.py | |
| +++ b/qa/rpc-tests/test_framework/blocktools.py | |
| @@ -8,7 +8,7 @@ from mininode import * | |
| from script import CScript, OP_TRUE, OP_CHECKSIG | |
| # Create a block (with regtest difficulty) | |
| -def create_block(hashprev, coinbase, nTime=None): | |
| +def create_block(hashprev, coinbase, nTime=None, nbits=0x207fffff): | |
| block = CBlock() | |
| if nTime is None: | |
| import time | |
| @@ -16,7 +16,7 @@ def create_block(hashprev, coinbase, nTime=None): | |
| else: | |
| block.nTime = nTime | |
| block.hashPrevBlock = hashprev | |
| - block.nBits = 0x207fffff # Will break after a difficulty adjustment... | |
| + block.nBits = nbits # default will break after a difficulty adjustment... | |
| block.vtx.append(coinbase) | |
| block.hashMerkleRoot = block.calc_merkle_root() | |
| block.calc_sha256() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment