Skip to content

Commit

Permalink
test: move HasReason so it can be reused
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Aug 10, 2021
1 parent d41adb4 commit 2455420
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@
// future: this should be MAINNET.
BOOST_FIXTURE_TEST_SUITE(miner_tests, WalletRegTestingSetup)

// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
class HasReason {
public:
HasReason(const std::string& reason) : m_reason(reason) {}
bool operator() (const std::runtime_error& e) const {
bool ret = std::string(e.what()).find(m_reason) != std::string::npos;
if (!ret) {
std::cout << "error: " << e.what() << std::endl;
}
return ret;
};
private:
const std::string m_reason;
};

static
struct {
unsigned char extranonce;
Expand Down
15 changes: 15 additions & 0 deletions src/test/test_pivx.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,19 @@ struct TestMemPoolEntryHelper
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
std::ostream& operator<<(std::ostream& os, const uint256& num);

// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
class HasReason {
public:
HasReason(const std::string& reason) : m_reason(reason) {}
bool operator() (const std::runtime_error& e) const {
bool ret = std::string(e.what()).find(m_reason) != std::string::npos;
if (!ret) {
std::cout << "error: " << e.what() << std::endl;
}
return ret;
};
private:
const std::string m_reason;
};

#endif

0 comments on commit 2455420

Please sign in to comment.