mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-12 12:53:31 +02:00
test: move HasReason so it can be reused
Move the class `HasReason` from `miner_tests.cpp` to `setup_common.h` so that it can be reused by other tests.
This commit is contained in:
parent
d2bb681f96
commit
fe42411b4b
@ -36,17 +36,6 @@ struct MinerTestingSetup : public TestingSetup {
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(miner_tests, MinerTestingSetup)
|
BOOST_FIXTURE_TEST_SUITE(miner_tests, MinerTestingSetup)
|
||||||
|
|
||||||
// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
|
|
||||||
class HasReason {
|
|
||||||
public:
|
|
||||||
explicit HasReason(const std::string& reason) : m_reason(reason) {}
|
|
||||||
bool operator() (const std::runtime_error& e) const {
|
|
||||||
return std::string(e.what()).find(m_reason) != std::string::npos;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
const std::string m_reason;
|
|
||||||
};
|
|
||||||
|
|
||||||
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
|
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
|
||||||
|
|
||||||
BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
|
BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
|
||||||
|
@ -153,4 +153,20 @@ CBlock getBlock13b8a();
|
|||||||
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
|
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
|
||||||
std::ostream& operator<<(std::ostream& os, const uint256& num);
|
std::ostream& operator<<(std::ostream& os, const uint256& num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
|
||||||
|
* Use as
|
||||||
|
* BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo"));
|
||||||
|
*/
|
||||||
|
class HasReason {
|
||||||
|
public:
|
||||||
|
explicit HasReason(const std::string& reason) : m_reason(reason) {}
|
||||||
|
template <typename E>
|
||||||
|
bool operator() (const E& e) const {
|
||||||
|
return std::string(e.what()).find(m_reason) != std::string::npos;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
const std::string m_reason;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user