Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
tx.vin[i].prevout.hash = GetRandHash(); | tx.vin[i].prevout.hash = GetRandHash(); | ||||
tx.vin[i].prevout.n = 0; | tx.vin[i].prevout.n = 0; | ||||
} | } | ||||
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); | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, | |||||
Params().GetConsensus())) | GlobalConfig config; | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, config)) { | |||||
++block.nNonce; | ++block.nNonce; | ||||
} | |||||
return block; | return block; | ||||
} | } | ||||
// Number of shared use_counts we expect for a tx we havent touched | // Number of shared use_counts we expect for a tx we havent touched | ||||
// == 2 (mempool + our copy from the GetSharedTx call) | // == 2 (mempool + our copy from the GetSharedTx call) | ||||
#define SHARED_TX_OFFSET 2 | #define SHARED_TX_OFFSET 2 | ||||
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { | BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest) { | ||||
block.vtx[0] = MakeTransactionRef(std::move(coinbase)); | block.vtx[0] = MakeTransactionRef(std::move(coinbase)); | ||||
block.nVersion = 42; | block.nVersion = 42; | ||||
block.hashPrevBlock = GetRandHash(); | block.hashPrevBlock = GetRandHash(); | ||||
block.nBits = 0x207fffff; | block.nBits = 0x207fffff; | ||||
bool mutated; | bool mutated; | ||||
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); | ||||
assert(!mutated); | assert(!mutated); | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, | |||||
Params().GetConsensus())) | GlobalConfig config; | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, config)) { | |||||
++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); | ||||
stream << shortIDs; | stream << shortIDs; | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |