Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show All 32 Lines | static CBlock BuildBlockTestCase() { | ||||
tx.vin.resize(1); | tx.vin.resize(1); | ||||
tx.vin[0].scriptSig.resize(10); | tx.vin[0].scriptSig.resize(10); | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = 42 * SATOSHI; | tx.vout[0].nValue = 42 * SATOSHI; | ||||
block.vtx.resize(3); | block.vtx.resize(3); | ||||
block.vtx[0] = MakeTransactionRef(tx); | block.vtx[0] = MakeTransactionRef(tx); | ||||
block.nVersion = 42; | block.nVersion = 42; | ||||
block.hashPrevBlock = InsecureRand256(); | block.hashPrevBlock = BlockHash(InsecureRand256()); | ||||
block.nBits = 0x207fffff; | block.nBits = 0x207fffff; | ||||
tx.vin[0].prevout = InsecureRandOutPoint(); | tx.vin[0].prevout = InsecureRandOutPoint(); | ||||
block.vtx[1] = MakeTransactionRef(tx); | block.vtx[1] = MakeTransactionRef(tx); | ||||
tx.vin.resize(10); | tx.vin.resize(10); | ||||
for (size_t i = 0; i < tx.vin.size(); i++) { | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
tx.vin[i].prevout = InsecureRandOutPoint(); | tx.vin[i].prevout = InsecureRandOutPoint(); | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest) { | ||||
coinbase.vin[0].scriptSig.resize(10); | coinbase.vin[0].scriptSig.resize(10); | ||||
coinbase.vout.resize(1); | coinbase.vout.resize(1); | ||||
coinbase.vout[0].nValue = 42 * SATOSHI; | coinbase.vout[0].nValue = 42 * SATOSHI; | ||||
CBlock block; | CBlock block; | ||||
block.vtx.resize(1); | block.vtx.resize(1); | ||||
block.vtx[0] = MakeTransactionRef(std::move(coinbase)); | block.vtx[0] = MakeTransactionRef(std::move(coinbase)); | ||||
block.nVersion = 42; | block.nVersion = 42; | ||||
block.hashPrevBlock = InsecureRand256(); | block.hashPrevBlock = BlockHash(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; | ||||
const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | ||||
Show All 25 Lines | // Test simple header round-trip with only coinbase | ||||
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), | BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), | ||||
BlockMerkleRoot(block2, &mutated).ToString()); | BlockMerkleRoot(block2, &mutated).ToString()); | ||||
BOOST_CHECK(!mutated); | BOOST_CHECK(!mutated); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(TransactionsRequestSerializationTest) { | BOOST_AUTO_TEST_CASE(TransactionsRequestSerializationTest) { | ||||
BlockTransactionsRequest req1; | BlockTransactionsRequest req1; | ||||
req1.blockhash = InsecureRand256(); | req1.blockhash = BlockHash(InsecureRand256()); | ||||
req1.indices.resize(4); | req1.indices.resize(4); | ||||
req1.indices[0] = 0; | req1.indices[0] = 0; | ||||
req1.indices[1] = 1; | req1.indices[1] = 1; | ||||
req1.indices[2] = 3; | req1.indices[2] = 3; | ||||
req1.indices[3] = 4; | req1.indices[3] = 4; | ||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); | ||||
stream << req1; | stream << req1; | ||||
Show All 13 Lines |