test: Add hashFinalSaplingProxy to create_block
This commit is contained in:
parent
0097df5c7a
commit
d7d4dd8a0f
|
@ -8,7 +8,7 @@ from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
|
||||||
from script import CScript, OP_0, OP_EQUAL, OP_HASH160
|
from script import CScript, OP_0, OP_EQUAL, OP_HASH160
|
||||||
|
|
||||||
# Create a block (with regtest difficulty)
|
# 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()
|
block = CBlock()
|
||||||
if nTime is None:
|
if nTime is None:
|
||||||
import time
|
import time
|
||||||
|
@ -16,6 +16,8 @@ def create_block(hashprev, coinbase, nTime=None, nBits=None):
|
||||||
else:
|
else:
|
||||||
block.nTime = nTime
|
block.nTime = nTime
|
||||||
block.hashPrevBlock = hashprev
|
block.hashPrevBlock = hashprev
|
||||||
|
if hashFinalSaplingRoot is not None:
|
||||||
|
block.hashFinalSaplingRoot = hashFinalSaplingRoot
|
||||||
if nBits is None:
|
if nBits is None:
|
||||||
block.nBits = 0x200f0f0f # Will break after a difficulty adjustment...
|
block.nBits = 0x200f0f0f # Will break after a difficulty adjustment...
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -786,7 +786,7 @@ class CBlockHeader(object):
|
||||||
self.nVersion = header.nVersion
|
self.nVersion = header.nVersion
|
||||||
self.hashPrevBlock = header.hashPrevBlock
|
self.hashPrevBlock = header.hashPrevBlock
|
||||||
self.hashMerkleRoot = header.hashMerkleRoot
|
self.hashMerkleRoot = header.hashMerkleRoot
|
||||||
self.hashReserved = header.hashReserved
|
self.hashFinalSaplingRoot = header.hashFinalSaplingRoot
|
||||||
self.nTime = header.nTime
|
self.nTime = header.nTime
|
||||||
self.nBits = header.nBits
|
self.nBits = header.nBits
|
||||||
self.nNonce = header.nNonce
|
self.nNonce = header.nNonce
|
||||||
|
@ -799,7 +799,7 @@ class CBlockHeader(object):
|
||||||
self.nVersion = 4
|
self.nVersion = 4
|
||||||
self.hashPrevBlock = 0
|
self.hashPrevBlock = 0
|
||||||
self.hashMerkleRoot = 0
|
self.hashMerkleRoot = 0
|
||||||
self.hashReserved = 0
|
self.hashFinalSaplingRoot = 0
|
||||||
self.nTime = 0
|
self.nTime = 0
|
||||||
self.nBits = 0
|
self.nBits = 0
|
||||||
self.nNonce = 0
|
self.nNonce = 0
|
||||||
|
@ -811,7 +811,7 @@ class CBlockHeader(object):
|
||||||
self.nVersion = struct.unpack("<i", f.read(4))[0]
|
self.nVersion = struct.unpack("<i", f.read(4))[0]
|
||||||
self.hashPrevBlock = deser_uint256(f)
|
self.hashPrevBlock = deser_uint256(f)
|
||||||
self.hashMerkleRoot = 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.nTime = struct.unpack("<I", f.read(4))[0]
|
||||||
self.nBits = struct.unpack("<I", f.read(4))[0]
|
self.nBits = struct.unpack("<I", f.read(4))[0]
|
||||||
self.nNonce = deser_uint256(f)
|
self.nNonce = deser_uint256(f)
|
||||||
|
@ -824,7 +824,7 @@ class CBlockHeader(object):
|
||||||
r += struct.pack("<i", self.nVersion)
|
r += struct.pack("<i", self.nVersion)
|
||||||
r += ser_uint256(self.hashPrevBlock)
|
r += ser_uint256(self.hashPrevBlock)
|
||||||
r += ser_uint256(self.hashMerkleRoot)
|
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.nTime)
|
||||||
r += struct.pack("<I", self.nBits)
|
r += struct.pack("<I", self.nBits)
|
||||||
r += ser_uint256(self.nNonce)
|
r += ser_uint256(self.nNonce)
|
||||||
|
@ -837,7 +837,7 @@ class CBlockHeader(object):
|
||||||
r += struct.pack("<i", self.nVersion)
|
r += struct.pack("<i", self.nVersion)
|
||||||
r += ser_uint256(self.hashPrevBlock)
|
r += ser_uint256(self.hashPrevBlock)
|
||||||
r += ser_uint256(self.hashMerkleRoot)
|
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.nTime)
|
||||||
r += struct.pack("<I", self.nBits)
|
r += struct.pack("<I", self.nBits)
|
||||||
r += ser_uint256(self.nNonce)
|
r += ser_uint256(self.nNonce)
|
||||||
|
@ -851,8 +851,8 @@ class CBlockHeader(object):
|
||||||
return self.sha256
|
return self.sha256
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashReserved=%064x nTime=%s nBits=%08x nNonce=%064x nSolution=%s)" \
|
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.hashReserved,
|
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, self.hashFinalSaplingRoot,
|
||||||
time.ctime(self.nTime), self.nBits, self.nNonce, repr(self.nSolution))
|
time.ctime(self.nTime), self.nBits, self.nNonce, repr(self.nSolution))
|
||||||
|
|
||||||
|
|
||||||
|
@ -923,9 +923,9 @@ class CBlock(CBlockHeader):
|
||||||
self.nNonce += 1
|
self.nNonce += 1
|
||||||
|
|
||||||
def __repr__(self):
|
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.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))
|
self.nNonce, repr(self.nSolution), repr(self.vtx))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue