Any projects which want to use Hush code from now on will need to be licensed as GPLv3 or we will send the lawyers: https://www.softwarefreedom.org/ Notably, Komodo (KMD) is licensed as GPLv2 and is no longer compatible to receive code changes, without causing legal issues. MIT projects, such as Zcash, also cannot pull in changes from the Hush Full Node without permission from The Hush Developers, which may in some circumstances grant an MIT license on a case-by-case basis.
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
// Copyright (c) 2015 The Bitcoin Core developers
|
|
// Distributed under the GPLv3 software license, see the accompanying
|
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
|
|
#include "reverselock.h"
|
|
#include "test/test_bitcoin.h"
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(reverselock_tests, BasicTestingSetup)
|
|
|
|
BOOST_AUTO_TEST_CASE(reverselock_basics)
|
|
{
|
|
boost::mutex mutex;
|
|
boost::unique_lock<boost::mutex> lock(mutex);
|
|
|
|
BOOST_CHECK(lock.owns_lock());
|
|
{
|
|
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
|
BOOST_CHECK(!lock.owns_lock());
|
|
}
|
|
BOOST_CHECK(lock.owns_lock());
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(reverselock_errors)
|
|
{
|
|
boost::mutex mutex;
|
|
boost::unique_lock<boost::mutex> lock(mutex);
|
|
|
|
// Make sure trying to reverse lock an unlocked lock fails
|
|
lock.unlock();
|
|
|
|
BOOST_CHECK(!lock.owns_lock());
|
|
|
|
bool failed = false;
|
|
try {
|
|
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
|
} catch(...) {
|
|
failed = true;
|
|
}
|
|
|
|
BOOST_CHECK(failed);
|
|
BOOST_CHECK(!lock.owns_lock());
|
|
|
|
// Locking the original lock after it has been taken by a reverse lock
|
|
// makes no sense. Ensure that the original lock no longer owns the lock
|
|
// after giving it to a reverse one.
|
|
|
|
lock.lock();
|
|
BOOST_CHECK(lock.owns_lock());
|
|
{
|
|
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
|
BOOST_CHECK(!lock.owns_lock());
|
|
}
|
|
|
|
BOOST_CHECK(failed);
|
|
BOOST_CHECK(lock.owns_lock());
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|