Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static CBlock BuildBlockTestCase() { | ||||
} | } | ||||
block.vtx[2] = MakeTransactionRef(tx); | block.vtx[2] = MakeTransactionRef(tx); | ||||
bool mutated; | bool mutated; | ||||
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | ||||
assert(!mutated); | assert(!mutated); | ||||
GlobalConfig config; | GlobalConfig config; | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, config)) { | const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, params)) { | |||||
++block.nNonce; | ++block.nNonce; | ||||
} | } | ||||
return block; | return block; | ||||
} | } | ||||
// Number of shared use_counts we expect for a tx we haven't touched | // Number of shared use_counts we expect for a tx we haven't touched | ||||
// (block + mempool + our copy from the GetSharedTx call) | // (block + mempool + our copy from the GetSharedTx call) | ||||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest) { | ||||
block.hashPrevBlock = InsecureRand256(); | block.hashPrevBlock = InsecureRand256(); | ||||
block.nBits = 0x207fffff; | block.nBits = 0x207fffff; | ||||
bool mutated; | bool mutated; | ||||
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | ||||
assert(!mutated); | assert(!mutated); | ||||
GlobalConfig config; | GlobalConfig config; | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, config)) { | const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, params)) { | |||||
++block.nNonce; | ++block.nNonce; | ||||
} | } | ||||
// Test simple header round-trip with only coinbase | // Test simple header round-trip with only coinbase | ||||
{ | { | ||||
CBlockHeaderAndShortTxIDs shortIDs(block); | CBlockHeaderAndShortTxIDs shortIDs(block); | ||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |