Error reporting improvements.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-10-13 20:13:19 +01:00
parent 14cce06163
commit 2ee172fe15
3 changed files with 8 additions and 4 deletions

View File

@ -214,7 +214,7 @@ def wait_for_bitcoind_start(process, url, i):
'''
while True:
if process.poll() is not None:
raise Exception('%s exited with status %i during initialization' % (zcashd_binary(), process.returncode))
raise Exception('%s node %d exited with status %i during initialization' % (zcashd_binary(), i, process.returncode))
try:
rpc = get_rpc_proxy(url, i)
rpc.getblockcount()
@ -433,7 +433,7 @@ def assert_start_raises_init_error(i, dirname, extra_args=None, expected_msg=Non
node = start_node(i, dirname, extra_args, stderr=log_stderr)
stop_node(node, i)
except Exception as e:
assert ("%s exited" % (zcashd_binary(),)) in str(e) #node must have shutdown
assert ("%s node %d exited" % (zcashd_binary(), i)) in str(e) # node must have shutdown
if expected_msg is not None:
log_stderr.seek(0)
stderr = log_stderr.read().decode('utf-8')

View File

@ -403,6 +403,7 @@ public:
uint256 GetBlockHash() const
{
assert(phashBlock);
return *phashBlock;
}
@ -432,7 +433,7 @@ public:
return strprintf("CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
pprev, nHeight,
hashMerkleRoot.ToString(),
GetBlockHash().ToString());
phashBlock ? GetBlockHash().ToString() : "(nil)");
}
//! Check whether this block index entry is valid up to the passed validity level.

View File

@ -613,9 +613,12 @@ bool CBlockTreeDB::LoadBlockIndexGuts(
// Consistency checks
auto header = pindexNew->GetBlockHeader();
if (header.GetHash() != diskindex.GetBlockHash())
return error("LoadBlockIndex(): inconsistent header vs diskindex hash: header hash = %s, diskindex hash = %s",
header.GetHash().ToString(), diskindex.GetBlockHash().ToString());
if (header.GetHash() != pindexNew->GetBlockHash())
return error("LoadBlockIndex(): block header inconsistency detected: on-disk = %s, in-memory = %s",
diskindex.ToString(), pindexNew->ToString());
diskindex.ToString(), pindexNew->ToString());
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());