Fix BIP65 and BIP66 tests
Blocks were being created that didn't satisfy the regtest consensus rules.
This commit is contained in:
parent
c10c40779d
commit
5455ca0d0e
|
@ -12,7 +12,6 @@ from test_framework.comptool import TestInstance, TestManager
|
||||||
from test_framework.script import CScript, OP_1NEGATE, OP_NOP2, OP_DROP
|
from test_framework.script import CScript, OP_1NEGATE, OP_NOP2, OP_DROP
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -64,9 +63,9 @@ class BIP65Test(ComparisonTestFramework):
|
||||||
|
|
||||||
def get_tests(self):
|
def get_tests(self):
|
||||||
self.coinbase_blocks = self.nodes[0].generate(1)
|
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||||
|
self.nodes[0].generate(100)
|
||||||
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
||||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
self.block_time = time.time() + 1
|
|
||||||
|
|
||||||
'''Check that the rules are enforced.'''
|
'''Check that the rules are enforced.'''
|
||||||
for valid in (True, False):
|
for valid in (True, False):
|
||||||
|
@ -77,7 +76,12 @@ class BIP65Test(ComparisonTestFramework):
|
||||||
self.invalidate_transaction(spendtx)
|
self.invalidate_transaction(spendtx)
|
||||||
spendtx.rehash()
|
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.nVersion = 4
|
||||||
block.vtx.append(spendtx)
|
block.vtx.append(spendtx)
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
|
|
|
@ -12,7 +12,6 @@ from test_framework.comptool import TestInstance, TestManager
|
||||||
from test_framework.script import CScript
|
from test_framework.script import CScript
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -71,9 +70,9 @@ class BIP66Test(ComparisonTestFramework):
|
||||||
|
|
||||||
def get_tests(self):
|
def get_tests(self):
|
||||||
self.coinbase_blocks = self.nodes[0].generate(1)
|
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||||
|
self.nodes[0].generate(100)
|
||||||
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
||||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
self.block_time = time.time() + 1
|
|
||||||
|
|
||||||
'''Check that the rules are enforced.'''
|
'''Check that the rules are enforced.'''
|
||||||
for valid in (True, False):
|
for valid in (True, False):
|
||||||
|
@ -84,13 +83,17 @@ class BIP66Test(ComparisonTestFramework):
|
||||||
self.invalidate_transaction(spendtx)
|
self.invalidate_transaction(spendtx)
|
||||||
spendtx.rehash()
|
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.nVersion = 4
|
||||||
block.vtx.append(spendtx)
|
block.vtx.append(spendtx)
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
self.block_time += 1
|
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
yield TestInstance([[block, valid]])
|
yield TestInstance([[block, valid]])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue