Fix BIP65 and BIP66 tests

Blocks were being created that didn't satisfy the regtest consensus rules.
This commit is contained in:
Jack Grigg 2017-10-04 01:21:09 +01:00
parent c10c40779d
commit 5455ca0d0e
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
2 changed files with 14 additions and 7 deletions

View File

@ -12,7 +12,6 @@ from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_NOP2, OP_DROP
from binascii import unhexlify
import cStringIO
import time
'''
@ -64,9 +63,9 @@ class BIP65Test(ComparisonTestFramework):
def get_tests(self):
self.coinbase_blocks = self.nodes[0].generate(1)
self.nodes[0].generate(100)
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.nodeaddress = self.nodes[0].getnewaddress()
self.block_time = time.time() + 1
'''Check that the rules are enforced.'''
for valid in (True, False):
@ -77,7 +76,12 @@ class BIP65Test(ComparisonTestFramework):
self.invalidate_transaction(spendtx)
spendtx.rehash()
block = create_block(self.tip, create_coinbase(1), self.block_time)
gbt = self.nodes[0].getblocktemplate()
self.block_time = gbt["mintime"] + 1
self.block_bits = int("0x" + gbt["bits"], 0)
block = create_block(self.tip, create_coinbase(101),
self.block_time, self.block_bits)
block.nVersion = 4
block.vtx.append(spendtx)
block.hashMerkleRoot = block.calc_merkle_root()

View File

@ -12,7 +12,6 @@ from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript
from binascii import unhexlify
import cStringIO
import time
'''
@ -71,9 +70,9 @@ class BIP66Test(ComparisonTestFramework):
def get_tests(self):
self.coinbase_blocks = self.nodes[0].generate(1)
self.nodes[0].generate(100)
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.nodeaddress = self.nodes[0].getnewaddress()
self.block_time = time.time() + 1
'''Check that the rules are enforced.'''
for valid in (True, False):
@ -84,13 +83,17 @@ class BIP66Test(ComparisonTestFramework):
self.invalidate_transaction(spendtx)
spendtx.rehash()
block = create_block(self.tip, create_coinbase(1), self.block_time)
gbt = self.nodes[0].getblocktemplate()
self.block_time = gbt["mintime"] + 1
self.block_bits = int("0x" + gbt["bits"], 0)
block = create_block(self.tip, create_coinbase(101),
self.block_time, self.block_bits)
block.nVersion = 4
block.vtx.append(spendtx)
block.hashMerkleRoot = block.calc_merkle_root()
block.rehash()
block.solve()
self.block_time += 1
self.tip = block.sha256
yield TestInstance([[block, valid]])