test: Add hashFinalSaplingProxy to create_block

This commit is contained in:
Jack Grigg 2019-07-19 14:08:00 +02:00
parent 0097df5c7a
commit d7d4dd8a0f
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
2 changed files with 12 additions and 10 deletions

View File

@ -8,7 +8,7 @@ from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
from script import CScript, OP_0, OP_EQUAL, OP_HASH160
# Create a block (with regtest difficulty)
def create_block(hashprev, coinbase, nTime=None, nBits=None):
def create_block(hashprev, coinbase, nTime=None, nBits=None, hashFinalSaplingRoot=None):
block = CBlock()
if nTime is None:
import time
@ -16,6 +16,8 @@ def create_block(hashprev, coinbase, nTime=None, nBits=None):
else:
block.nTime = nTime
block.hashPrevBlock = hashprev
if hashFinalSaplingRoot is not None:
block.hashFinalSaplingRoot = hashFinalSaplingRoot
if nBits is None:
block.nBits = 0x200f0f0f # Will break after a difficulty adjustment...
else:

View File

@ -786,7 +786,7 @@ class CBlockHeader(object):
self.nVersion = header.nVersion
self.hashPrevBlock = header.hashPrevBlock
self.hashMerkleRoot = header.hashMerkleRoot
self.hashReserved = header.hashReserved
self.hashFinalSaplingRoot = header.hashFinalSaplingRoot
self.nTime = header.nTime
self.nBits = header.nBits
self.nNonce = header.nNonce
@ -799,7 +799,7 @@ class CBlockHeader(object):
self.nVersion = 4
self.hashPrevBlock = 0
self.hashMerkleRoot = 0
self.hashReserved = 0
self.hashFinalSaplingRoot = 0
self.nTime = 0
self.nBits = 0
self.nNonce = 0
@ -811,7 +811,7 @@ class CBlockHeader(object):
self.nVersion = struct.unpack("<i", f.read(4))[0]
self.hashPrevBlock = deser_uint256(f)
self.hashMerkleRoot = deser_uint256(f)
self.hashReserved = deser_uint256(f)
self.hashFinalSaplingRoot = deser_uint256(f)
self.nTime = struct.unpack("<I", f.read(4))[0]
self.nBits = struct.unpack("<I", f.read(4))[0]
self.nNonce = deser_uint256(f)
@ -824,7 +824,7 @@ class CBlockHeader(object):
r += struct.pack("<i", self.nVersion)
r += ser_uint256(self.hashPrevBlock)
r += ser_uint256(self.hashMerkleRoot)
r += ser_uint256(self.hashReserved)
r += ser_uint256(self.hashFinalSaplingRoot)
r += struct.pack("<I", self.nTime)
r += struct.pack("<I", self.nBits)
r += ser_uint256(self.nNonce)
@ -837,7 +837,7 @@ class CBlockHeader(object):
r += struct.pack("<i", self.nVersion)
r += ser_uint256(self.hashPrevBlock)
r += ser_uint256(self.hashMerkleRoot)
r += ser_uint256(self.hashReserved)
r += ser_uint256(self.hashFinalSaplingRoot)
r += struct.pack("<I", self.nTime)
r += struct.pack("<I", self.nBits)
r += ser_uint256(self.nNonce)
@ -851,8 +851,8 @@ class CBlockHeader(object):
return self.sha256
def __repr__(self):
return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashReserved=%064x nTime=%s nBits=%08x nNonce=%064x nSolution=%s)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, self.hashReserved,
return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashFinalSaplingRoot=%064x nTime=%s nBits=%08x nNonce=%064x nSolution=%s)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, self.hashFinalSaplingRoot,
time.ctime(self.nTime), self.nBits, self.nNonce, repr(self.nSolution))
@ -923,9 +923,9 @@ class CBlock(CBlockHeader):
self.nNonce += 1
def __repr__(self):
return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashReserved=%064x nTime=%s nBits=%08x nNonce=%064x nSolution=%s vtx=%s)" \
return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashFinalSaplingRoot=%064x nTime=%s nBits=%08x nNonce=%064x nSolution=%s vtx=%s)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,
self.hashReserved, time.ctime(self.nTime), self.nBits,
self.hashFinalSaplingRoot, time.ctime(self.nTime), self.nBits,
self.nNonce, repr(self.nSolution), repr(self.vtx))