mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
commit
26752767df
@ -67,6 +67,7 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
def get_tests(self):
|
def get_tests(self):
|
||||||
|
|
||||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||||
|
height = 3 # height of the next block to build
|
||||||
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.last_block_time = time.time()
|
self.last_block_time = time.time()
|
||||||
@ -74,25 +75,27 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
''' 98 more version 3 blocks '''
|
''' 98 more version 3 blocks '''
|
||||||
test_blocks = []
|
test_blocks = []
|
||||||
for i in xrange(98):
|
for i in xrange(98):
|
||||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
test_blocks.append([block, True])
|
test_blocks.append([block, True])
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance(test_blocks, sync_every_block=False)
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
''' Mine 749 version 4 blocks '''
|
''' Mine 749 version 4 blocks '''
|
||||||
test_blocks = []
|
test_blocks = []
|
||||||
for i in xrange(749):
|
for i in xrange(749):
|
||||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 4
|
block.nVersion = 4
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
test_blocks.append([block, True])
|
test_blocks.append([block, True])
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance(test_blocks, sync_every_block=False)
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -104,7 +107,7 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
cltv_invalidate(spendtx)
|
cltv_invalidate(spendtx)
|
||||||
spendtx.rehash()
|
spendtx.rehash()
|
||||||
|
|
||||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
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()
|
||||||
@ -113,6 +116,7 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
|
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance([[block, True]])
|
yield TestInstance([[block, True]])
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -124,7 +128,7 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
cltv_invalidate(spendtx)
|
cltv_invalidate(spendtx)
|
||||||
spendtx.rehash()
|
spendtx.rehash()
|
||||||
|
|
||||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
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()
|
||||||
@ -136,35 +140,38 @@ class BIP65Test(ComparisonTestFramework):
|
|||||||
''' Mine 199 new version blocks on last valid tip '''
|
''' Mine 199 new version blocks on last valid tip '''
|
||||||
test_blocks = []
|
test_blocks = []
|
||||||
for i in xrange(199):
|
for i in xrange(199):
|
||||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 4
|
block.nVersion = 4
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
test_blocks.append([block, True])
|
test_blocks.append([block, True])
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance(test_blocks, sync_every_block=False)
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
''' Mine 1 old version block '''
|
''' Mine 1 old version block '''
|
||||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance([[block, True]])
|
yield TestInstance([[block, True]])
|
||||||
|
|
||||||
''' Mine 1 new version block '''
|
''' Mine 1 new version block '''
|
||||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 4
|
block.nVersion = 4
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
self.last_block_time += 1
|
self.last_block_time += 1
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
height += 1
|
||||||
yield TestInstance([[block, True]])
|
yield TestInstance([[block, True]])
|
||||||
|
|
||||||
''' Mine 1 old version block, should be invalid '''
|
''' Mine 1 old version block, should be invalid '''
|
||||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block.solve()
|
block.solve()
|
||||||
|
Loading…
Reference in New Issue
Block a user