Merge pull request #6703
45bfa13PARTIAL: typofixes (found by misspell_fixer) (Veres Lajos)21c406eadd support for miniupnpc api version 14 (Pavel Vasin)13bd5a7rpc-tests: re-enable rpc-tests for Windows (Cory Fields)ccc4ad6net: Set SO_REUSEADDR for Windows too (Cory Fields)1f6772eadd unit test for CNetAddr::GetGroup. (Alex Morcos)13642a5Fix masking of irrelevant bits in address groups. (Alex Morcos)6b51b9bReplace boost::reverse_lock with our own. (Casey Rodarmor)626c5e6Make sure we re-acquire lock if a task throws (Casey Rodarmor)4877053Add missing files to files.md (fanquake)f171feeHandle leveldb::DestroyDB() errors on wipe failure (Adam Weiss)c5b89feFix race condition on test node shutdown (Casey Rodarmor)4a37410Handle no chain tip available in InvalidChainFound() (Ross Nicoll)f6d29a6Use unique name for AlertNotify tempfile (Casey Rodarmor)e6adac7Delay initial pruning until after wallet init (Adam Weiss)e0020d4Make sure LogPrint strings are line-terminated (J Ross Nicoll)7ff9d12Make sure LogPrintf strings are line-terminated (Wladimir J. van der Laan)5a39133build: fix libressl detection (Cory Fields)f6355e6Avoid leaking file descriptors in RegisterLoad (Casey Rodarmor)60457d3locking: fix a few small issues uncovered by -Wthread-safety (Cory Fields)a496e11Remove bash test note from rpc-tests readme (fanquake)49c6a64tests: Remove old sh-based test framework (Wladimir J. van der Laan)a37567dAdd autogen.sh to source tarball. (randy-waterhouse)1f4d7cftravis: for travis generating an extra build (Cory Fields)
This commit is contained in:
@@ -117,6 +117,7 @@ BITCOIN_CORE_H = \
|
||||
protocol.h \
|
||||
pubkey.h \
|
||||
random.h \
|
||||
reverselock.h \
|
||||
rpcclient.h \
|
||||
rpcprotocol.h \
|
||||
rpcserver.h \
|
||||
|
||||
@@ -59,6 +59,7 @@ BITCOIN_TESTS =\
|
||||
test/pmt_tests.cpp \
|
||||
test/policyestimator_tests.cpp \
|
||||
test/pow_tests.cpp \
|
||||
test/reverselock_tests.cpp \
|
||||
test/rpc_tests.cpp \
|
||||
test/sanity_tests.cpp \
|
||||
test/scheduler_tests.cpp \
|
||||
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
* Notice that vvTried, mapAddr and vVector are never encoded explicitly;
|
||||
* they are instead reconstructed from the other information.
|
||||
*
|
||||
* vvNew is serialized, but only used if ADDRMAN_UNKOWN_BUCKET_COUNT didn't change,
|
||||
* vvNew is serialized, but only used if ADDRMAN_UNKNOWN_BUCKET_COUNT didn't change,
|
||||
* otherwise it is reconstructed as well.
|
||||
*
|
||||
* This format is more complex, but significantly smaller (at most 1.5 MiB), and supports
|
||||
|
||||
@@ -142,13 +142,14 @@ static void RegisterLoad(const string& strInput)
|
||||
valStr.insert(valStr.size(), buf, bread);
|
||||
}
|
||||
|
||||
if (ferror(f)) {
|
||||
int error = ferror(f);
|
||||
fclose(f);
|
||||
|
||||
if (error) {
|
||||
string strErr = "Error reading file " + filename;
|
||||
throw runtime_error(strErr);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
// evaluate as JSON buffer register
|
||||
RegisterSetJson(key, valStr);
|
||||
}
|
||||
|
||||
27
src/init.cpp
27
src/init.cpp
@@ -1223,15 +1223,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
mempool.ReadFeeEstimates(est_filein);
|
||||
fFeeEstimatesInitialized = true;
|
||||
|
||||
// if prune mode, unset NODE_NETWORK and prune block files
|
||||
if (fPruneMode) {
|
||||
LogPrintf("Unsetting NODE_NETWORK on prune mode\n");
|
||||
nLocalServices &= ~NODE_NETWORK;
|
||||
if (!fReindex) {
|
||||
PruneAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************* Step 8: load wallet
|
||||
#ifdef ENABLE_WALLET
|
||||
if (fDisableWallet) {
|
||||
@@ -1372,7 +1363,21 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
#else // ENABLE_WALLET
|
||||
LogPrintf("No wallet support compiled in!\n");
|
||||
#endif // !ENABLE_WALLET
|
||||
// ********************************************************* Step 9: import blocks
|
||||
|
||||
// ********************************************************* Step 9: data directory maintenance
|
||||
|
||||
// if pruning, unset the service bit and perform the initial blockstore prune
|
||||
// after any wallet rescanning has taken place.
|
||||
if (fPruneMode) {
|
||||
uiInterface.InitMessage(_("Pruning blockstore..."));
|
||||
LogPrintf("Unsetting NODE_NETWORK on prune mode\n");
|
||||
nLocalServices &= ~NODE_NETWORK;
|
||||
if (!fReindex) {
|
||||
PruneAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************* Step 10: import blocks
|
||||
|
||||
if (mapArgs.count("-blocknotify"))
|
||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||
@@ -1396,7 +1401,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
MilliSleep(10);
|
||||
}
|
||||
|
||||
// ********************************************************* Step 10: start node
|
||||
// ********************************************************* Step 11: start node
|
||||
|
||||
if (!CheckDiskSpace())
|
||||
return false;
|
||||
|
||||
@@ -58,7 +58,8 @@ CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCa
|
||||
} else {
|
||||
if (fWipe) {
|
||||
LogPrintf("Wiping LevelDB in %s\n", path.string());
|
||||
leveldb::DestroyDB(path.string(), options);
|
||||
leveldb::Status result = leveldb::DestroyDB(path.string(), options);
|
||||
HandleError(result);
|
||||
}
|
||||
TryCreateDirectory(path);
|
||||
LogPrintf("Opening LevelDB in %s\n", path.string());
|
||||
|
||||
10
src/main.cpp
10
src/main.cpp
@@ -1331,9 +1331,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
|
||||
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S",
|
||||
pindexNew->GetBlockTime()));
|
||||
CBlockIndex *tip = chainActive.Tip();
|
||||
assert (tip);
|
||||
LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__,
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()));
|
||||
tip->GetBlockHash().ToString(), chainActive.Height(), log(tip->nChainWork.getdouble())/log(2.0),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", tip->GetBlockTime()));
|
||||
CheckForkWarningConditions();
|
||||
}
|
||||
|
||||
@@ -1561,7 +1563,7 @@ bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
||||
strMiscWarning = strMessage;
|
||||
LogPrintf("*** %s\n", strMessage);
|
||||
uiInterface.ThreadSafeMessageBox(
|
||||
userMessage.empty() ? _("Error: A fatal internal error occured, see debug.log for details") : userMessage,
|
||||
userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage,
|
||||
"", CClientUIInterface::MSG_ERROR);
|
||||
StartShutdown();
|
||||
return false;
|
||||
@@ -3508,7 +3510,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
LogPrintf("%s: Deserialize or I/O error - %s", __func__, e.what());
|
||||
LogPrintf("%s: Deserialize or I/O error - %s\n", __func__, e.what());
|
||||
}
|
||||
}
|
||||
} catch (const std::runtime_error& e) {
|
||||
|
||||
@@ -168,7 +168,7 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch) {
|
||||
// traverse the partial tree
|
||||
unsigned int nBitsUsed = 0, nHashUsed = 0;
|
||||
uint256 hashMerkleRoot = TraverseAndExtract(nHeight, 0, nBitsUsed, nHashUsed, vMatch);
|
||||
// verify that no problems occured during the tree traversal
|
||||
// verify that no problems occurred during the tree traversal
|
||||
if (fBad)
|
||||
return uint256();
|
||||
// verify that all bits were consumed (except for the padding caused by serializing it as a byte sequence)
|
||||
|
||||
16
src/net.cpp
16
src/net.cpp
@@ -554,7 +554,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
||||
return false;
|
||||
|
||||
if (msg.in_data && msg.hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) {
|
||||
LogPrint("net", "Oversized message from peer=%i, disconnecting", GetId());
|
||||
LogPrint("net", "Oversized message from peer=%i, disconnecting\n", GetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1007,10 +1007,14 @@ void ThreadMapPort()
|
||||
#ifndef UPNPDISCOVER_SUCCESS
|
||||
/* miniupnpc 1.5 */
|
||||
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
|
||||
#else
|
||||
#elif MINIUPNPC_API_VERSION < 14
|
||||
/* miniupnpc 1.6 */
|
||||
int error = 0;
|
||||
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
|
||||
#else
|
||||
/* miniupnpc 1.9.20150730 */
|
||||
int error = 0;
|
||||
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error);
|
||||
#endif
|
||||
|
||||
struct UPNPUrls urls;
|
||||
@@ -1502,8 +1506,10 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
|
||||
#endif
|
||||
// Allow binding if the port is still in TIME_WAIT state after
|
||||
// the program was closed and restarted. Not an issue on windows!
|
||||
// the program was closed and restarted.
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
|
||||
#else
|
||||
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int));
|
||||
#endif
|
||||
|
||||
// Set to non-blocking, incoming connections will also inherit this
|
||||
@@ -2052,8 +2058,10 @@ void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||
Fuzz(GetArg("-fuzzmessagestest", 10));
|
||||
|
||||
if (ssSend.size() == 0)
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||
return;
|
||||
|
||||
}
|
||||
// Set the size
|
||||
unsigned int nSize = ssSend.size() - CMessageHeader::HEADER_SIZE;
|
||||
WriteLE32((uint8_t*)&ssSend[CMessageHeader::MESSAGE_SIZE_OFFSET], nSize);
|
||||
|
||||
@@ -349,7 +349,7 @@ static bool Socks5(const std::string& strDest, int port, const ProxyCredentials
|
||||
}
|
||||
if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) {
|
||||
CloseSocket(hSocket);
|
||||
return error("Proxy authentication unsuccesful");
|
||||
return error("Proxy authentication unsuccessful");
|
||||
}
|
||||
} else if (pchRet1[1] == 0x00) {
|
||||
// Perform no authentication
|
||||
@@ -983,7 +983,7 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
|
||||
nBits -= 8;
|
||||
}
|
||||
if (nBits > 0)
|
||||
vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1));
|
||||
vchRet.push_back(GetByte(15 - nStartByte) | ((1 << (8 - nBits)) - 1));
|
||||
|
||||
return vchRet;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ unsigned int TxConfirmStats::NewTx(unsigned int nBlockHeight, double val)
|
||||
unsigned int bucketindex = bucketMap.lower_bound(val)->second;
|
||||
unsigned int blockIndex = nBlockHeight % unconfTxs.size();
|
||||
unconfTxs[blockIndex][bucketindex]++;
|
||||
LogPrint("estimatefee", "adding to %s\n", dataTypeString);
|
||||
LogPrint("estimatefee", "adding to %s", dataTypeString);
|
||||
return bucketindex;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ void TxConfirmStats::removeTx(unsigned int entryHeight, unsigned int nBestSeenHe
|
||||
blocksAgo = 0;
|
||||
if (blocksAgo < 0) {
|
||||
LogPrint("estimatefee", "Blockpolicy error, blocks ago is negative for mempool tx\n");
|
||||
return; //This can't happen becasue we call this with our best seen height, no entries can have higher
|
||||
return; //This can't happen because we call this with our best seen height, no entries can have higher
|
||||
}
|
||||
|
||||
if (blocksAgo >= (int)unconfTxs.size()) {
|
||||
@@ -390,8 +390,9 @@ void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, boo
|
||||
mapMemPoolTxs[hash].bucketIndex = feeStats.NewTx(txHeight, (double)feeRate.GetFeePerK());
|
||||
}
|
||||
else {
|
||||
LogPrint("estimatefee", "not adding\n");
|
||||
LogPrint("estimatefee", "not adding");
|
||||
}
|
||||
LogPrint("estimatefee", "\n");
|
||||
}
|
||||
|
||||
void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry& entry)
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
/**
|
||||
* Initialize the data structures. This is called by BlockPolicyEstimator's
|
||||
* constructor with default values.
|
||||
* @param defaultBuckets contains the upper limits for the bucket boundries
|
||||
* @param defaultBuckets contains the upper limits for the bucket boundaries
|
||||
* @param maxConfirms max number of confirms to track
|
||||
* @param decay how much to decay the historical moving average per block
|
||||
* @param dataTypeString for logging purposes
|
||||
|
||||
@@ -764,7 +764,7 @@ void PaymentServer::setOptionsModel(OptionsModel *optionsModel)
|
||||
|
||||
void PaymentServer::handlePaymentACK(const QString& paymentACKMsg)
|
||||
{
|
||||
// currently we don't futher process or store the paymentACK message
|
||||
// currently we don't further process or store the paymentACK message
|
||||
Q_EMIT message(tr("Payment acknowledged"), paymentACKMsg, CClientUIInterface::ICON_INFORMATION | CClientUIInterface::MODAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ void RPCConsole::peerLayoutChanged()
|
||||
|
||||
if (detailNodeRow < 0)
|
||||
{
|
||||
// detail node dissapeared from table (node disconnected)
|
||||
// detail node disappeared from table (node disconnected)
|
||||
fUnselect = true;
|
||||
cachedNodeid = -1;
|
||||
ui->detailWidget->hide();
|
||||
|
||||
@@ -57,7 +57,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
||||
QPainter pixPaint(&pixmap);
|
||||
pixPaint.setPen(QColor(100,100,100));
|
||||
|
||||
// draw a slighly radial gradient
|
||||
// draw a slightly radial gradient
|
||||
QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
|
||||
gradient.setColorAt(0, Qt::white);
|
||||
gradient.setColorAt(1, QColor(247,247,247));
|
||||
|
||||
31
src/reverselock.h
Normal file
31
src/reverselock.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_REVERSELOCK_H
|
||||
#define BITCOIN_REVERSELOCK_H
|
||||
|
||||
/**
|
||||
* An RAII-style reverse lock. Unlocks on construction and locks on destruction.
|
||||
*/
|
||||
template<typename Lock>
|
||||
class reverse_lock
|
||||
{
|
||||
public:
|
||||
|
||||
explicit reverse_lock(Lock& lock) : lock(lock) {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
~reverse_lock() {
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
private:
|
||||
reverse_lock(reverse_lock const&);
|
||||
reverse_lock& operator=(reverse_lock const&);
|
||||
|
||||
Lock& lock;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_REVERSELOCK_H
|
||||
@@ -673,7 +673,7 @@ void StartRPCThreads()
|
||||
vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v6::any(), defaultPort));
|
||||
vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v4::any(), defaultPort));
|
||||
// Prefer making the socket dual IPv6/IPv4 instead of binding
|
||||
// to both addresses seperately.
|
||||
// to both addresses separately.
|
||||
bBindAny = true;
|
||||
}
|
||||
|
||||
@@ -755,14 +755,14 @@ void StopRPCThreads()
|
||||
{
|
||||
acceptor->cancel(ec);
|
||||
if (ec)
|
||||
LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message());
|
||||
LogPrintf("%s: Warning: %s when cancelling acceptor\n", __func__, ec.message());
|
||||
}
|
||||
rpc_acceptors.clear();
|
||||
BOOST_FOREACH(const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers)
|
||||
{
|
||||
timer.second->cancel(ec);
|
||||
if (ec)
|
||||
LogPrintf("%s: Warning: %s when cancelling timer", __func__, ec.message());
|
||||
LogPrintf("%s: Warning: %s when cancelling timer\n", __func__, ec.message());
|
||||
}
|
||||
deadlineTimers.clear();
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "scheduler.h"
|
||||
|
||||
#include "reverselock.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <utility>
|
||||
@@ -65,11 +67,12 @@ void CScheduler::serviceQueue()
|
||||
Function f = taskQueue.begin()->second;
|
||||
taskQueue.erase(taskQueue.begin());
|
||||
|
||||
// Unlock before calling f, so it can reschedule itself or another task
|
||||
// without deadlocking:
|
||||
lock.unlock();
|
||||
f();
|
||||
lock.lock();
|
||||
{
|
||||
// Unlock before calling f, so it can reschedule itself or another task
|
||||
// without deadlocking:
|
||||
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
||||
f();
|
||||
}
|
||||
} catch (...) {
|
||||
--nThreadsServicingQueue;
|
||||
throw;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// //
|
||||
// THE SIMPLE DEFINITON, EXCLUDING DEBUG CODE //
|
||||
// THE SIMPLE DEFINITION, EXCLUDING DEBUG CODE //
|
||||
// //
|
||||
////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
|
||||
SetMockTime(11);
|
||||
const std::vector<unsigned char>& alertKey = Params(CBaseChainParams::MAIN).AlertKey();
|
||||
|
||||
boost::filesystem::path temp = GetTempPath() / "alertnotify.txt";
|
||||
boost::filesystem::remove(temp);
|
||||
boost::filesystem::path temp = GetTempPath() /
|
||||
boost::filesystem::unique_path("alertnotify-%%%%.txt");
|
||||
|
||||
mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
@@ -145,4 +146,20 @@ BOOST_AUTO_TEST_CASE(subnet_test)
|
||||
BOOST_CHECK(!CSubNet("fuzzy").IsValid());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(netbase_getgroup)
|
||||
{
|
||||
BOOST_CHECK(CNetAddr("127.0.0.1").GetGroup() == boost::assign::list_of(0)); // Local -> !Routable()
|
||||
BOOST_CHECK(CNetAddr("257.0.0.1").GetGroup() == boost::assign::list_of(0)); // !Valid -> !Routable()
|
||||
BOOST_CHECK(CNetAddr("10.0.0.1").GetGroup() == boost::assign::list_of(0)); // RFC1918 -> !Routable()
|
||||
BOOST_CHECK(CNetAddr("169.254.1.1").GetGroup() == boost::assign::list_of(0)); // RFC3927 -> !Routable()
|
||||
BOOST_CHECK(CNetAddr("1.2.3.4").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // IPv4
|
||||
BOOST_CHECK(CNetAddr("::FFFF:0:102:304").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC6145
|
||||
BOOST_CHECK(CNetAddr("64:FF9B::102:304").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC6052
|
||||
BOOST_CHECK(CNetAddr("2002:102:304:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC3964
|
||||
BOOST_CHECK(CNetAddr("2001:0:9999:9999:9999:9999:FEFD:FCFB").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC4380
|
||||
BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup() == boost::assign::list_of((unsigned char)NET_TOR)(239)); // Tor
|
||||
BOOST_CHECK(CNetAddr("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV6)(32)(1)(4)(112)(175)); //he.net
|
||||
BOOST_CHECK(CNetAddr("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV6)(32)(1)(32)(1)); //IPv6
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
64
src/test/reverselock_tests.cpp
Normal file
64
src/test/reverselock_tests.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#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());
|
||||
|
||||
// Make sure trying to lock a lock after it has been reverse locked fails
|
||||
failed = false;
|
||||
bool locked = false;
|
||||
|
||||
lock.lock();
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
|
||||
try {
|
||||
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
||||
lock.lock();
|
||||
locked = true;
|
||||
} catch(...) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
BOOST_CHECK(locked && failed);
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -341,7 +341,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const
|
||||
minerPolicyEstimator->Write(fileout);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
LogPrintf("CTxMemPool::WriteFeeEstimates(): unable to write policy estimator data (non-fatal)");
|
||||
LogPrintf("CTxMemPool::WriteFeeEstimates(): unable to write policy estimator data (non-fatal)\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -360,7 +360,7 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
|
||||
minerPolicyEstimator->Read(filein);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
LogPrintf("CTxMemPool::ReadFeeEstimates(): unable to read policy estimator data (non-fatal)");
|
||||
LogPrintf("CTxMemPool::ReadFeeEstimates(): unable to read policy estimator data (non-fatal)\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -114,7 +114,7 @@ CTranslationInterface translationInterface;
|
||||
|
||||
/** Init OpenSSL library multithreading support */
|
||||
static CCriticalSection** ppmutexOpenSSL;
|
||||
void locking_callback(int mode, int i, const char* file, int line)
|
||||
void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAFETY_ANALYSIS
|
||||
{
|
||||
if (mode & CRYPTO_LOCK) {
|
||||
ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]);
|
||||
|
||||
@@ -186,7 +186,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
|
||||
}
|
||||
if (keyPass && keyFail)
|
||||
{
|
||||
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.");
|
||||
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
|
||||
assert(false);
|
||||
}
|
||||
if (keyFail || !keyPass)
|
||||
|
||||
@@ -476,7 +476,6 @@ Value listaddressgroupings(const Array& params, bool fHelp)
|
||||
addressInfo.push_back(CBitcoinAddress(address).ToString());
|
||||
addressInfo.push_back(ValueFromAmount(balances[address]));
|
||||
{
|
||||
LOCK(pwalletMain->cs_wallet);
|
||||
if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end())
|
||||
addressInfo.push_back(pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second.name);
|
||||
}
|
||||
@@ -796,7 +795,7 @@ Value movecmd(const Array& params, bool fHelp)
|
||||
"3. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n"
|
||||
"4. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n"
|
||||
"\nResult:\n"
|
||||
"true|false (boolean) true if successfull.\n"
|
||||
"true|false (boolean) true if successful.\n"
|
||||
"\nExamples:\n"
|
||||
"\nMove 0.01 btc from the default account to the account named tabby\n"
|
||||
+ HelpExampleCli("move", "\"\" \"tabby\" 0.01") +
|
||||
|
||||
@@ -2001,7 +2001,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
||||
if (!wtxNew.AcceptToMemoryPool(false))
|
||||
{
|
||||
// This must not fail. The transaction has already been signed and recorded.
|
||||
LogPrintf("CommitTransaction(): Error: Transaction not valid");
|
||||
LogPrintf("CommitTransaction(): Error: Transaction not valid\n");
|
||||
return false;
|
||||
}
|
||||
wtxNew.RelayWalletTransaction();
|
||||
|
||||
Reference in New Issue
Block a user