File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -36,17 +36,6 @@ struct MinerTestingSetup : public TestingSetup {
3636
3737BOOST_FIXTURE_TEST_SUITE (miner_tests, MinerTestingSetup)
3838
39- // BOOST_CHECK_EXCEPTION predicates to check the specific validation error
40- class HasReason {
41- public:
42- explicit HasReason (const std::string& reason) : m_reason (reason) {}
43- bool operator () (const std::runtime_error& e) const {
44- return std::string (e.what ()).find (m_reason) != std::string::npos;
45- };
46- private:
47- const std::string m_reason;
48- };
49-
5039static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
5140
5241BlockAssembler MinerTestingSetup::AssemblerForTest (const CChainParams& params)
Original file line number Diff line number Diff line change @@ -153,4 +153,20 @@ CBlock getBlock13b8a();
153153// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
154154std::ostream& operator <<(std::ostream& os, const uint256& num);
155155
156+ /* *
157+ * BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
158+ * Use as
159+ * BOOST_CHECK_EXCEPTION(code that throws, exception type, HasReason("foo"));
160+ */
161+ class HasReason {
162+ public:
163+ explicit HasReason (const std::string& reason) : m_reason(reason) {}
164+ template <typename E>
165+ bool operator () (const E& e) const {
166+ return std::string (e.what ()).find (m_reason) != std::string::npos;
167+ };
168+ private:
169+ const std::string m_reason;
170+ };
171+
156172#endif
You can’t perform that action at this time.
0 commit comments