Changeset View
Changeset View
Standalone View
Standalone View
src/test/blockencodings_tests.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static CBlock BuildBlockTestCase() { | ||||
const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | ||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, params)) { | while (!CheckProofOfWork(block.GetHash(), block.nBits, params)) { | ||||
++block.nNonce; | ++block.nNonce; | ||||
} | } | ||||
return block; | return block; | ||||
} | } | ||||
// BOOST_CHECK_EXCEPTION predicates to check the exception message | |||||
class HasReason { | |||||
public: | |||||
explicit HasReason(const std::string &reason) : m_reason(reason) {} | |||||
bool operator()(const std::exception &e) const { | |||||
return std::string(e.what()).find(m_reason) != std::string::npos; | |||||
}; | |||||
private: | |||||
const std::string m_reason; | |||||
}; | |||||
// 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) | ||||
constexpr long SHARED_TX_OFFSET{3}; | constexpr long SHARED_TX_OFFSET{3}; | ||||
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { | BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { | ||||
CTxMemPool pool; | CTxMemPool pool; | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
CBlock block(BuildBlockTestCase()); | CBlock block(BuildBlockTestCase()); | ||||
▲ Show 20 Lines • Show All 392 Lines • Show Last 20 Lines |