Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show All 17 Lines | |||||
std::vector<std::pair<uint256, CTransactionRef>> extra_txn; | std::vector<std::pair<uint256, CTransactionRef>> extra_txn; | ||||
struct RegtestingSetup : public TestingSetup { | struct RegtestingSetup : public TestingSetup { | ||||
RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST) {} | RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST) {} | ||||
}; | }; | ||||
BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup) | BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup) | ||||
static COutPoint InsecureRandOutPoint() { | |||||
return COutPoint(TxId(InsecureRand256()), 0); | |||||
} | |||||
static CBlock BuildBlockTestCase() { | static CBlock BuildBlockTestCase() { | ||||
CBlock block; | CBlock block; | ||||
CMutableTransaction tx; | CMutableTransaction tx; | ||||
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 = InsecureRand256(); | ||||
block.nBits = 0x207fffff; | block.nBits = 0x207fffff; | ||||
tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); | 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 = COutPoint(InsecureRand256(), 0); | tx.vin[i].prevout = InsecureRandOutPoint(); | ||||
} | } | ||||
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; | ||||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |