From 12dd1013454a3b4913e8e6bbac251887e7e82ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Tue, 24 Jul 2018 16:59:49 +0100 Subject: [PATCH] scripted-diff: Remove trailing whitespaces -BEGIN VERIFY SCRIPT- sed --in-place'' --regexp-extended 's/[[:space:]]+$//g' $(git grep -I --files-with-matches --extended-regexp '[[:space:]]+$' -- src test ':!*.svg' ':!src/crypto/sha256_sse4*' ':!src/leveldb' ':!src/qt/locale' ':!src/secp256k1' ':!src/univalue') -END VERIFY SCRIPT- --- src/Makefile.qt.include | 2 +- src/addrman.cpp | 2 +- src/addrman.h | 4 +- src/bloom.cpp | 2 +- src/bloom.h | 4 +- src/checkqueue.h | 4 +- src/clientversion.cpp | 4 +- src/coins.h | 4 +- src/consensus/tx_verify.h | 2 +- src/core_read.cpp | 4 +- src/httprpc.cpp | 2 +- src/limitedmap.h | 2 +- src/qt/bitcoingui.cpp | 6 +- src/qt/bitcoingui.h | 2 +- src/qt/guiutil.cpp | 18 +++--- src/qt/guiutil.h | 4 +- src/qt/macdockiconhandler.mm | 6 +- src/qt/macnotificationhandler.mm | 2 +- src/qt/modaloverlay.cpp | 2 +- src/qt/optionsdialog.h | 2 +- src/qt/optionsmodel.cpp | 2 +- src/qt/qvalidatedlineedit.h | 2 +- src/qt/trafficgraphwidget.cpp | 2 +- src/qt/walletview.cpp | 2 +- src/reverse_iterator.h | 10 ++-- src/script/interpreter.cpp | 6 +- src/serialize.h | 10 ++-- src/streams.h | 4 +- src/test/README.md | 12 ++-- src/test/data/key_io_invalid.json | 98 +++++++++++++++---------------- src/test/data/script_tests.json | 2 +- src/test/dbwrapper_tests.cpp | 12 ++-- src/test/limitedmap_tests.cpp | 4 +- src/test/mempool_tests.cpp | 2 +- src/test/net_tests.cpp | 2 +- src/test/prevector_tests.cpp | 2 +- src/test/raii_event_tests.cpp | 8 +-- src/test/script_tests.cpp | 2 +- src/test/serialize_tests.cpp | 4 +- src/test/streams_tests.cpp | 20 +++---- src/timedata.h | 2 +- src/txdb.cpp | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 2 +- src/validation.h | 6 +- test/README.md | 6 +- 46 files changed, 152 insertions(+), 152 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a84a11ac4..c7a196313 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -357,7 +357,7 @@ if ENABLE_WALLET BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_CPP) endif -RES_IMAGES = +RES_IMAGES = RES_MOVIES = $(wildcard $(srcdir)/qt/res/movies/spinner-*.png) diff --git a/src/addrman.cpp b/src/addrman.cpp index e811dd4be..3337ec54d 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -356,7 +356,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) // Use a 50% chance for choosing between tried and new table entries. if (!newOnly && - (nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) { + (nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) { // use a tried node double fChanceFactor = 1.0; while (1) { diff --git a/src/addrman.h b/src/addrman.h index a36f7ea10..dc8ef8375 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -182,8 +182,8 @@ public: //! the maximum number of tried addr collisions to store #define ADDRMAN_SET_TRIED_COLLISION_SIZE 10 -/** - * Stochastical (IP) address manager +/** + * Stochastical (IP) address manager */ class CAddrMan { diff --git a/src/bloom.cpp b/src/bloom.cpp index f8e28edde..799e0eef0 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -148,7 +148,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) const CTxOut& txout = tx.vout[i]; // Match if the filter contains any arbitrary script data element in any scriptPubKey in tx // If this matches, also add the specific output that was matched. - // This means clients don't have to update the filter themselves when a new relevant tx + // This means clients don't have to update the filter themselves when a new relevant tx // is discovered in order to find spending transactions, which avoids round-tripping and race conditions. CScript::const_iterator pc = txout.scriptPubKey.begin(); std::vector data; diff --git a/src/bloom.h b/src/bloom.h index 2f9d2109c..71386f52f 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -33,9 +33,9 @@ enum bloomflags /** * BloomFilter is a probabilistic filter which SPV clients provide * so that we can filter the transactions we send them. - * + * * This allows for significantly more efficient transaction and block downloads. - * + * * Because bloom filters are probabilistic, a SPV node can increase the false- * positive rate, making us send it transactions which aren't actually its, * allowing clients to trade more bandwidth for more privacy by obfuscating which diff --git a/src/checkqueue.h b/src/checkqueue.h index 7500bae60..84360d071 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -16,7 +16,7 @@ template class CCheckQueueControl; -/** +/** * Queue for verifications that have to be performed. * The verifications are represented by a type T, which must provide an * operator(), returning a bool. @@ -163,7 +163,7 @@ public: }; -/** +/** * RAII-style controller object for a CCheckQueue that guarantees the passed * queue is finished before continuing. */ diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 662fbb6e7..a3eb127ca 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -81,8 +81,8 @@ std::string FormatFullVersion() return CLIENT_BUILD; } -/** - * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) +/** + * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) { diff --git a/src/coins.h b/src/coins.h index a73f016a3..89685ce4b 100644 --- a/src/coins.h +++ b/src/coins.h @@ -203,7 +203,7 @@ class CCoinsViewCache : public CCoinsViewBacked protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -280,7 +280,7 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of bitcoins coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. diff --git a/src/consensus/tx_verify.h b/src/consensus/tx_verify.h index a4836ceda..50db1775a 100644 --- a/src/consensus/tx_verify.h +++ b/src/consensus/tx_verify.h @@ -41,7 +41,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** * Count ECDSA signature operations in pay-to-script-hash inputs. - * + * * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return maximum number of sigops required to validate this transaction's inputs * @see CTransaction::FetchInputs diff --git a/src/core_read.cpp b/src/core_read.cpp index 067e1b91b..64283f740 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -105,7 +105,7 @@ static bool CheckTxScriptsSanity(const CMutableTransaction& tx) return false; } } - + return true; } @@ -140,7 +140,7 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no // Fall through. } } - + return false; } diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 97b152b11..0e5b49796 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -86,7 +86,7 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni //This function checks username and password against -rpcauth //entries from config file. static bool multiUserAuthorized(std::string strUserPass) -{ +{ if (strUserPass.find(':') == std::string::npos) { return false; } diff --git a/src/limitedmap.h b/src/limitedmap.h index d5f00f1fe..22dde5ec3 100644 --- a/src/limitedmap.h +++ b/src/limitedmap.h @@ -70,7 +70,7 @@ public: // since it is a constant time operation in C++11. For more details, see // https://stackoverflow.com/questions/765148/how-to-remove-constness-of-const-iterator iterator itTarget = map.erase(itIn, itIn); - + if (itTarget == map.end()) return; std::pair itPair = rmap.equal_range(itTarget->second); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 2438361a5..c8f8b9c7d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -470,13 +470,13 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) } #endif // ENABLE_WALLET unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); - + OptionsModel* optionsModel = _clientModel->getOptionsModel(); if(optionsModel) { // be aware of the tray icon disable state change reported by the OptionsModel object. connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool))); - + // initialize the disable state of the tray icon with the current value in the model. setTrayIconVisible(optionsModel->getHideTrayIcon()); } @@ -1057,7 +1057,7 @@ void BitcoinGUI::setHDStatus(int hdEnabled) labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is enabled") : tr("HD key generation is disabled")); - // eventually disable the QLabel to set its opacity to 50% + // eventually disable the QLabel to set its opacity to 50% labelWalletHDStatusIcon->setEnabled(hdEnabled); } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 4deeb325b..d7ca8081d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -262,7 +262,7 @@ private Q_SLOTS: /** Show progress dialog e.g. for verifychain */ void showProgress(const QString &title, int nProgress); - + /** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */ void setTrayIconVisible(bool); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index acd9f7b35..fd9b5b622 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -381,12 +381,12 @@ bool openBitcoinConf() /* Create the file */ boost::filesystem::ofstream configFile(pathConfig, std::ios_base::app); - + if (!configFile.good()) return false; - + configFile.close(); - + /* Open bitcoin.conf with the associated application */ return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig))); } @@ -741,7 +741,7 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef if (listSnapshot == nullptr) { return nullptr; } - + // loop through the list of startup items and try to find the bitcoin app for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); @@ -769,7 +769,7 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef CFRelease(currentItemURL); } } - + CFRelease(listSnapshot); return nullptr; } @@ -780,7 +780,7 @@ bool GetStartOnSystemStartup() if (bitcoinAppUrl == nullptr) { return false; } - + LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); @@ -794,7 +794,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) if (bitcoinAppUrl == nullptr) { return false; } - + LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); @@ -806,7 +806,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) // remove item LSSharedFileListItemRemove(loginItems, foundItem); } - + CFRelease(bitcoinAppUrl); return true; } @@ -967,7 +967,7 @@ void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) { Q_EMIT clicked(event->pos()); } - + void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event) { Q_EMIT clicked(event->pos()); diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index e965a91d1..5d09ccdae 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -219,11 +219,11 @@ namespace GUIUtil protected: void mouseReleaseEvent(QMouseEvent *event); }; - + class ClickableProgressBar : public QProgressBar { Q_OBJECT - + Q_SIGNALS: /** Emitted when the progressbar is clicked. The relative mouse coordinates of the click are * passed to the signal. diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm index a0b62ae00..b9ad191da 100644 --- a/src/qt/macdockiconhandler.mm +++ b/src/qt/macdockiconhandler.mm @@ -19,9 +19,9 @@ static MacDockIconHandler *s_instance = nullptr; bool dockClickHandler(id self,SEL _cmd,...) { Q_UNUSED(self) Q_UNUSED(_cmd) - + s_instance->handleDockIconClickEvent(); - + // Return NO (false) to suppress the default OS X actions return false; } @@ -29,7 +29,7 @@ bool dockClickHandler(id self,SEL _cmd,...) { void setupDockClickHandler() { Class cls = objc_getClass("NSApplication"); id appInst = objc_msgSend((id)cls, sel_registerName("sharedApplication")); - + if (appInst != nullptr) { id delegate = objc_msgSend(appInst, sel_registerName("delegate")); Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class")); diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm index 1b16c5f52..0e04d50ba 100644 --- a/src/qt/macnotificationhandler.mm +++ b/src/qt/macnotificationhandler.mm @@ -64,7 +64,7 @@ MacNotificationHandler *MacNotificationHandler::instance() static MacNotificationHandler *s_instance = nullptr; if (!s_instance) { s_instance = new MacNotificationHandler(); - + Class aPossibleClass = objc_getClass("NSBundle"); if (aPossibleClass) { // change NSBundle -bundleIdentifier method to return a correct bundle identifier diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp index 249418213..e9d03c582 100644 --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -104,7 +104,7 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri ui->progressIncreasePerH->setText(QString::number(progressPerHour * 100, 'f', 2)+"%"); // show expected remaining time - if(remainingMSecs >= 0) { + if(remainingMSecs >= 0) { ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0)); } else { ui->expectedTimeLeft->setText(QObject::tr("unknown")); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 5aad484ce..54e1a8a9b 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -50,7 +50,7 @@ private Q_SLOTS: void on_openBitcoinConfButton_clicked(); void on_okButton_clicked(); void on_cancelButton_clicked(); - + void on_hideTrayIcon_stateChanged(int fState); void togglePruneWarning(bool enabled); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 31a85f4e2..834ff7633 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -57,7 +57,7 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("fHideTrayIcon", false); fHideTrayIcon = settings.value("fHideTrayIcon").toBool(); Q_EMIT hideTrayIconChanged(fHideTrayIcon); - + if (!settings.contains("fMinimizeToTray")) settings.setValue("fMinimizeToTray", false); fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && !fHideTrayIcon; diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h index 66734cc9d..9ad9e66ae 100644 --- a/src/qt/qvalidatedlineedit.h +++ b/src/qt/qvalidatedlineedit.h @@ -34,7 +34,7 @@ public Q_SLOTS: Q_SIGNALS: void validationDidChange(QValidatedLineEdit *validatedLineEdit); - + private Q_SLOTS: void markValid(); void checkValidity(); diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index 5a3b645f6..a5551ec01 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -80,7 +80,7 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *) const QString units = tr("KB/s"); const float yMarginText = 2.0; - + // draw lines painter.setPen(axisCol); painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 %2").arg(val).arg(units)); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index d529595de..c53a2910e 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -107,7 +107,7 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui) // Pass through transaction notifications connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString,QString))); - // Connect HD enabled state signal + // Connect HD enabled state signal connect(this, SIGNAL(hdEnabledStatusChanged()), gui, SLOT(updateWalletStatus())); } } diff --git a/src/reverse_iterator.h b/src/reverse_iterator.h index ab467f07c..729d8c11c 100644 --- a/src/reverse_iterator.h +++ b/src/reverse_iterator.h @@ -5,7 +5,7 @@ /** * Template used for reverse iteration in C++11 range-based for loops. - * + * * std::vector v = {1, 2, 3, 4, 5}; * for (auto x : reverse_iterate(v)) * std::cout << x << " "; @@ -15,21 +15,21 @@ template class reverse_range { T &m_x; - + public: explicit reverse_range(T &x) : m_x(x) {} - + auto begin() const -> decltype(this->m_x.rbegin()) { return m_x.rbegin(); } - + auto end() const -> decltype(this->m_x.rend()) { return m_x.rend(); } }; - + template reverse_range reverse_iterate(T &x) { diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 4b982d647..1936d44cd 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -99,7 +99,7 @@ bool static IsCompressedPubKey(const valtype &vchPubKey) { * Where R and S are not negative (their first byte has its highest bit not set), and not * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, * in which case a single 0 byte is necessary and even required). - * + * * See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 * * This function is consensus-critical since BIP66. @@ -139,7 +139,7 @@ bool static IsValidSignatureEncoding(const std::vector &sig) { // Verify that the length of the signature matches the sum of the length // of the elements. if ((size_t)(lenR + lenS + 7) != sig.size()) return false; - + // Check whether the R element is an integer. if (sig[2] != 0x02) return false; @@ -899,7 +899,7 @@ bool EvalScript(std::vector >& stack, const CScript& popstack(stack); stack.push_back(vchHash); } - break; + break; case OP_CODESEPARATOR: { diff --git a/src/serialize.h b/src/serialize.h index 627225b6e..99d4c893f 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -173,11 +173,11 @@ template const X& ReadWriteAsHelper(const X& x) { return x; } #define READWRITE(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) #define READWRITEAS(type, obj) (::SerReadWriteMany(s, ser_action, ReadWriteAsHelper(obj))) -/** +/** * Implement three methods for serializable objects. These are actually wrappers over * "SerializationOp" template, which implements the body of each class' serialization * code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be - * added as members. + * added as members. */ #define ADD_SERIALIZE_METHODS \ template \ @@ -312,16 +312,16 @@ uint64_t ReadCompactSize(Stream& is) * sure the encoding is one-to-one, one is subtracted from all but the last digit. * Thus, the byte sequence a[] with length len, where all but the last byte * has bit 128 set, encodes the number: - * + * * (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) - * + * * Properties: * * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) * * Every integer has exactly one encoding * * Encoding does not depend on size of original integer type * * No redundancy: every (infinite) byte sequence corresponds to a list * of encoded integers. - * + * * 0: [0x00] 256: [0x81 0x00] * 1: [0x01] 16383: [0xFE 0x7F] * 127: [0x7F] 16384: [0xFF 0x00] diff --git a/src/streams.h b/src/streams.h index 6ba4f103d..ed2e985d7 100644 --- a/src/streams.h +++ b/src/streams.h @@ -348,7 +348,7 @@ public: if (nReadPosNext > vch.size()) { throw std::ios_base::failure("CDataStream::read(): end of data"); } - memcpy(pch, &vch[nReadPos], nSize); + memcpy(pch, &vch[nReadPos], nSize); if (nReadPosNext == vch.size()) { nReadPos = 0; @@ -456,7 +456,7 @@ private: const int nType; const int nVersion; - FILE* file; + FILE* file; public: CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) diff --git a/src/test/README.md b/src/test/README.md index 01da32109..f2a4cb181 100644 --- a/src/test/README.md +++ b/src/test/README.md @@ -42,12 +42,12 @@ unit tests as possible). The build system is setup to compile an executable called `test_bitcoin` that runs all of the unit tests. The main source file is called -test_bitcoin.cpp. To add a new unit test file to our test suite you need -to add the file to `src/Makefile.test.include`. The pattern is to create -one test file for each class or source file for which you want to create -unit tests. The file naming convention is `_tests.cpp` -and such files should wrap their tests in a test suite -called `_tests`. For an example of this pattern, +test_bitcoin.cpp. To add a new unit test file to our test suite you need +to add the file to `src/Makefile.test.include`. The pattern is to create +one test file for each class or source file for which you want to create +unit tests. The file naming convention is `_tests.cpp` +and such files should wrap their tests in a test suite +called `_tests`. For an example of this pattern, examine `uint256_tests.cpp`. For further reading, I found the following website to be helpful in diff --git a/src/test/data/key_io_invalid.json b/src/test/data/key_io_invalid.json index 2056c7491..9b52943ac 100644 --- a/src/test/data/key_io_invalid.json +++ b/src/test/data/key_io_invalid.json @@ -1,151 +1,151 @@ [ [ "" - ], + ], [ "x" - ], + ], [ "37qgekLpCCHrQuSjvX3fs496FWTGsHFHizjJAs6NPcR47aefnnCWECAhHV6E3g4YN7u7Yuwod5Y" - ], + ], [ "dzb7VV1Ui55BARxv7ATxAtCUeJsANKovDGWFVgpTbhq9gvPqP3yv" - ], + ], [ "MuNu7ZAEDFiHthiunm7dPjwKqrVNCM3mAz6rP9zFveQu14YA8CxExSJTHcVP9DErn6u84E6Ej7S" - ], + ], [ "rPpQpYknyNQ5AEHuY6H8ijJJrYc2nDKKk9jjmKEXsWzyAQcFGpDLU2Zvsmoi8JLR7hAwoy3RQWf" - ], + ], [ "4Uc3FmN6NQ6zLBK5QQBXRBUREaaHwCZYsGCueHauuDmJpZKn6jkEskMB2Zi2CNgtb5r6epWEFfUJq" - ], + ], [ "7aQgR5DFQ25vyXmqZAWmnVCjL3PkBcdVkBUpjrjMTcghHx3E8wb" - ], + ], [ "17QpPprjeg69fW1DV8DcYYCKvWjYhXvWkov6MJ1iTTvMFj6weAqW7wybZeH57WTNxXVCRH4veVs" - ], + ], [ "KxuACDviz8Xvpn1xAh9MfopySZNuyajYMZWz16Dv2mHHryznWUp3" - ], + ], [ "7nK3GSmqdXJQtdohvGfJ7KsSmn3TmGqExug49583bDAL91pVSGq5xS9SHoAYL3Wv3ijKTit65th" - ], + ], [ "cTivdBmq7bay3RFGEBBuNfMh2P1pDCgRYN2Wbxmgwr4ki3jNUL2va" - ], + ], [ "gjMV4vjNjyMrna4fsAr8bWxAbwtmMUBXJS3zL4NJt5qjozpbQLmAfK1uA3CquSqsZQMpoD1g2nk" - ], + ], [ "emXm1naBMoVzPjbk7xpeTVMFy4oDEe25UmoyGgKEB1gGWsK8kRGs" - ], + ], [ "7VThQnNRj1o3Zyvc7XHPRrjDf8j2oivPTeDXnRPYWeYGE4pXeRJDZgf28ppti5hsHWXS2GSobdqyo" - ], + ], [ "1G9u6oCVCPh2o8m3t55ACiYvG1y5BHewUkDSdiQarDcYXXhFHYdzMdYfUAhfxn5vNZBwpgUNpso" - ], + ], [ "31QQ7ZMLkScDiB4VyZjuptr7AEc9j1SjstF7pRoLhHTGkW4Q2y9XELobQmhhWxeRvqcukGd1XCq" - ], + ], [ "DHqKSnpxa8ZdQyH8keAhvLTrfkyBMQxqngcQA5N8LQ9KVt25kmGN" - ], + ], [ "2LUHcJPbwLCy9GLH1qXmfmAwvadWw4bp4PCpDfduLqV17s6iDcy1imUwhQJhAoNoN1XNmweiJP4i" - ], + ], [ "7USRzBXAnmck8fX9HmW7RAb4qt92VFX6soCnts9s74wxm4gguVhtG5of8fZGbNPJA83irHVY6bCos" - ], + ], [ "1DGezo7BfVebZxAbNT3XGujdeHyNNBF3vnficYoTSp4PfK2QaML9bHzAMxke3wdKdHYWmsMTJVu" - ], + ], [ "2D12DqDZKwCxxkzs1ZATJWvgJGhQ4cFi3WrizQ5zLAyhN5HxuAJ1yMYaJp8GuYsTLLxTAz6otCfb" - ], + ], [ "8AFJzuTujXjw1Z6M3fWhQ1ujDW7zsV4ePeVjVo7D1egERqSW9nZ" - ], + ], [ "163Q17qLbTCue8YY3AvjpUhotuaodLm2uqMhpYirsKjVqnxJRWTEoywMVY3NbBAHuhAJ2cF9GAZ" - ], + ], [ "2MnmgiRH4eGLyLc9eAqStzk7dFgBjFtUCtu" - ], + ], [ "461QQ2sYWxU7H2PV4oBwJGNch8XVTYYbZxU" - ], + ], [ "2UCtv53VttmQYkVU4VMtXB31REvQg4ABzs41AEKZ8UcB7DAfVzdkV9JDErwGwyj5AUHLkmgZeobs" - ], + ], [ "cSNjAsnhgtiFMi6MtfvgscMB2Cbhn2v1FUYfviJ1CdjfidvmeW6mn" - ], + ], [ "gmsow2Y6EWAFDFE1CE4Hd3Tpu2BvfmBfG1SXsuRARbnt1WjkZnFh1qGTiptWWbjsq2Q6qvpgJVj" - ], + ], [ "nksUKSkzS76v8EsSgozXGMoQFiCoCHzCVajFKAXqzK5on9ZJYVHMD5CKwgmX3S3c7M1U3xabUny" - ], + ], [ "L3favK1UzFGgdzYBF2oBT5tbayCo4vtVBLJhg2iYuMeePxWG8SQc" - ], + ], [ "7VxLxGGtYT6N99GdEfi6xz56xdQ8nP2dG1CavuXx7Rf2PrvNMTBNevjkfgs9JmkcGm6EXpj8ipyPZ" - ], + ], [ "2mbZwFXF6cxShaCo2czTRB62WTx9LxhTtpP" - ], + ], [ "dB7cwYdcPSgiyAwKWL3JwCVwSk6epU2txw" - ], + ], [ "HPhFUhUAh8ZQQisH8QQWafAxtQYju3SFTX" - ], + ], [ "4ctAH6AkHzq5ioiM1m9T3E2hiYEev5mTsB" - ], + ], [ "Hn1uFi4dNexWrqARpjMqgT6cX1UsNPuV3cHdGg9ExyXw8HTKadbktRDtdeVmY3M1BxJStiL4vjJ" - ], + ], [ "Sq3fDbvutABmnAHHExJDgPLQn44KnNC7UsXuT7KZecpaYDMU9Txs" - ], + ], [ "6TqWyrqdgUEYDQU1aChMuFMMEimHX44qHFzCUgGfqxGgZNMUVWJ" - ], + ], [ "giqJo7oWqFxNKWyrgcBxAVHXnjJ1t6cGoEffce5Y1y7u649Noj5wJ4mmiUAKEVVrYAGg2KPB3Y4" - ], + ], [ "cNzHY5e8vcmM3QVJUcjCyiKMYfeYvyueq5qCMV3kqcySoLyGLYUK" - ], + ], [ "37uTe568EYc9WLoHEd9jXEvUiWbq5LFLscNyqvAzLU5vBArUJA6eydkLmnMwJDjkL5kXc2VK7ig" - ], + ], [ "EsYbG4tWWWY45G31nox838qNdzksbPySWc" - ], + ], [ "nbuzhfwMoNzA3PaFnyLcRxE9bTJPDkjZ6Rf6Y6o2ckXZfzZzXBT" - ], + ], [ "cQN9PoxZeCWK1x56xnz6QYAsvR11XAce3Ehp3gMUdfSQ53Y2mPzx" - ], + ], [ "1Gm3N3rkef6iMbx4voBzaxtXcmmiMTqZPhcuAepRzYUJQW4qRpEnHvMojzof42hjFRf8PE2jPde" - ], + ], [ "2TAq2tuN6x6m233bpT7yqdYQPELdTDJn1eU" - ], + ], [ "ntEtnnGhqPii4joABvBtSEJG6BxjT2tUZqE8PcVYgk3RHpgxgHDCQxNbLJf7ardf1dDk2oCQ7Cf" - ], + ], [ "Ky1YjoZNgQ196HJV3HpdkecfhRBmRZdMJk89Hi5KGfpfPwS2bUbfd" - ], + ], [ "2A1q1YsMZowabbvta7kTy2Fd6qN4r5ZCeG3qLpvZBMzCixMUdkN2Y4dHB1wPsZAeVXUGD83MfRED" ], diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json index 97edc98bf..9b320b694 100644 --- a/src/test/data/script_tests.json +++ b/src/test/data/script_tests.json @@ -712,7 +712,7 @@ ["0x17 0x3014020002107777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Zero-length R is correctly encoded"], ["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "", "OK", "Zero-length S is correctly encoded for DERSIG"], ["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Negative S is correctly encoded"], - + ["2147483648", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "OK", "CSV passes if stack top bit 1 << 31 is set"], ["", "DEPTH", "P2SH,STRICTENC", "EVAL_FALSE", "Test the test: we should have an empty stack after scriptSig evaluation"], diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index fac7418cb..5ba54ef9b 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -20,9 +20,9 @@ static bool is_null_key(const std::vector& key) { return isnull; } - + BOOST_FIXTURE_TEST_SUITE(dbwrapper_tests, BasicTestingSetup) - + BOOST_AUTO_TEST_CASE(dbwrapper) { // Perform tests both obfuscated and non-obfuscated. @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) // Now, set up another wrapper that wants to obfuscate the same directory CDBWrapper odbw(ph, (1 << 10), false, false, true); - // Check that the key/val we wrote with unobfuscated wrapper exists and + // Check that the key/val we wrote with unobfuscated wrapper exists and // is readable. uint256 res2; BOOST_CHECK(odbw.Read(key, res2)); @@ -153,13 +153,13 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) uint256 in2 = InsecureRand256(); uint256 res3; - + // Check that we can write successfully BOOST_CHECK(odbw.Write(key, in2)); BOOST_CHECK(odbw.Read(key, res3)); BOOST_CHECK_EQUAL(res3.ToString(), in2.ToString()); } - + // Ensure that we start obfuscating during a reindex. BOOST_AUTO_TEST_CASE(existing_data_reindex) { @@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex) uint256 in2 = InsecureRand256(); uint256 res3; - + // Check that we can write successfully BOOST_CHECK(odbw.Write(key, in2)); BOOST_CHECK(odbw.Read(key, res3)); diff --git a/src/test/limitedmap_tests.cpp b/src/test/limitedmap_tests.cpp index a4bd63cde..7871ff6f7 100644 --- a/src/test/limitedmap_tests.cpp +++ b/src/test/limitedmap_tests.cpp @@ -50,10 +50,10 @@ BOOST_AUTO_TEST_CASE(limitedmap_test) // use the iterator to check for the expected key and value BOOST_CHECK(it->first == i); BOOST_CHECK(it->second == i + 1); - + // use find to check for the value BOOST_CHECK(map.find(i)->second == i + 1); - + // update and recheck map.update(it, i + 2); BOOST_CHECK(map.find(i)->second == i + 2); diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 0264d2945..e2d76dc29 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) poolSize = testPool.size(); testPool.removeRecursive(txParent); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1); - + // Parent, children, grandchildren: testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); for (int i = 0; i < 3; i++) diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 2a77e0e1e..f7861d9b8 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test) in_addr ipv4Addr; ipv4Addr.s_addr = 0xa0b0c001; - + CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK); std::string pszDest; bool fInboundIn = false; diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index fe6f10d84..5f0000935 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -36,7 +36,7 @@ class prevector_tester { { local_check(a == b); } - void local_check(bool b) + void local_check(bool b) { passed &= b; } diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp index 7bc81c7f6..3dfa09e09 100644 --- a/src/test/raii_event_tests.cpp +++ b/src/test/raii_event_tests.cpp @@ -41,7 +41,7 @@ BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(raii_event_creation) { event_set_mem_functions(tag_malloc, realloc, tag_free); - + void* base_ptr = nullptr; { auto base = obtain_event_base(); @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(raii_event_creation) BOOST_CHECK(tags[base_ptr] == 1); } BOOST_CHECK(tags[base_ptr] == 0); - + void* event_ptr = nullptr; { auto base = obtain_event_base(); @@ -63,14 +63,14 @@ BOOST_AUTO_TEST_CASE(raii_event_creation) } BOOST_CHECK(tags[base_ptr] == 0); BOOST_CHECK(tags[event_ptr] == 0); - + event_set_mem_functions(malloc, realloc, free); } BOOST_AUTO_TEST_CASE(raii_event_order) { event_set_mem_functions(tag_malloc, realloc, tag_free); - + void* base_ptr = nullptr; void* event_ptr = nullptr; { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 543b21e8a..510910e14 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -515,7 +515,7 @@ BOOST_AUTO_TEST_CASE(script_build) tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, "P2SH(P2PK), bad redeemscript", SCRIPT_VERIFY_P2SH, true ).PushSig(keys.key0).PushRedeem().DamagePush(10).ScriptError(SCRIPT_ERR_EVAL_FALSE)); - + tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.pubkey0.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG, "P2SH(P2PKH)", SCRIPT_VERIFY_P2SH, true ).PushSig(keys.key0).Push(keys.pubkey0).PushRedeem()); diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index eba58e004..a0dafaaf5 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -252,8 +252,8 @@ static bool isCanonicalException(const std::ios_base::failure& ex) // The string returned by what() can be different for different platforms. // Instead of directly comparing the ex.what() with an expected string, - // create an instance of exception to see if ex.what() matches - // the expected explanatory string returned by the exception instance. + // create an instance of exception to see if ex.what() matches + // the expected explanatory string returned by the exception instance. return strcmp(expectedException.what(), ex.what()) == 0; } diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index e1e77f7c9..8ca668ba0 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -76,19 +76,19 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) CDataStream ds(in, 0, 0); // Degenerate case - + key.push_back('\x00'); key.push_back('\x00'); ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), + std::string(expected_xor.begin(), expected_xor.end()), std::string(ds.begin(), ds.end())); in.push_back('\x0f'); in.push_back('\xf0'); expected_xor.push_back('\xf0'); expected_xor.push_back('\x0f'); - + // Single character key ds.clear(); @@ -98,9 +98,9 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) key.push_back('\xff'); ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), - std::string(ds.begin(), ds.end())); - + std::string(expected_xor.begin(), expected_xor.end()), + std::string(ds.begin(), ds.end())); + // Multi character key in.clear(); @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) in.push_back('\x0f'); expected_xor.push_back('\x0f'); expected_xor.push_back('\x00'); - + ds.clear(); ds.insert(ds.begin(), in.begin(), in.end()); @@ -119,8 +119,8 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), - std::string(ds.begin(), ds.end())); -} + std::string(expected_xor.begin(), expected_xor.end()), + std::string(ds.begin(), ds.end())); +} BOOST_AUTO_TEST_SUITE_END() diff --git a/src/timedata.h b/src/timedata.h index 23584f67e..a4fefb598 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -14,7 +14,7 @@ static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT = 70 * 60; class CNetAddr; -/** +/** * Median filter over a stream of values. * Returns the median of the last N numbers */ diff --git a/src/txdb.cpp b/src/txdb.cpp index 3635d0ab4..1fc791944 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -53,7 +53,7 @@ struct CoinEntry { } -CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) +CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) { } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index d579f131c..2108e6ba2 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -284,7 +284,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // should be a bit faster. // However, if we happen to be in the middle of processing a reorg, then // the mempool can be in an inconsistent state. In this case, the set - // of ancestors reachable via mapLinks will be the same as the set of + // of ancestors reachable via mapLinks will be the same as the set of // ancestors whose packages include this transaction, because when we // add a new transaction to the mempool in addUnchecked(), we assume it // has no children, and in the case of a reorg where that assumption is diff --git a/src/txmempool.h b/src/txmempool.h index 784d5453b..f3b8a68a9 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -692,7 +692,7 @@ private: void removeUnchecked(txiter entry, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs); }; -/** +/** * CCoinsView that brings transactions from a mempool into view. * It does not check for spendings by memory pool transactions. * Instead, it provides access to all Coins which are either unspent in the diff --git a/src/validation.h b/src/validation.h index 869f847cd..1aff10f02 100644 --- a/src/validation.h +++ b/src/validation.h @@ -207,7 +207,7 @@ static const unsigned int DEFAULT_CHECKLEVEL = 3; // Setting the target to > than 550MB will make it likely we can respect the target. static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; -/** +/** * Process an incoming block. This only returns after the best known valid * block is made active. Note that it does not, however, guarantee that the * specific block passed to it has been checked for validity! @@ -218,7 +218,7 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; * * Note that we guarantee that either the proof-of-work is valid on pblock, or * (and possibly also) BlockChecked will have been called. - * + * * May not be called in a * validationinterface callback. * @@ -351,7 +351,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp = null /** * Closure representing one script verification - * Note that this stores references to the spending transaction + * Note that this stores references to the spending transaction */ class CScriptCheck { diff --git a/test/README.md b/test/README.md index b522c4469..a5ba732bc 100644 --- a/test/README.md +++ b/test/README.md @@ -5,7 +5,7 @@ etc. There are currently two sets of tests in this directory: -- [functional](/test/functional) which test the functionality of +- [functional](/test/functional) which test the functionality of bitcoind and bitcoin-qt by interacting with them through the RPC and P2P interfaces. - [util](/test/util) which tests the bitcoin utilities, currently only @@ -177,11 +177,11 @@ Note: gdb attach step may require `sudo` ### Util tests -Util tests can be run locally by running `test/util/bitcoin-util-test.py`. +Util tests can be run locally by running `test/util/bitcoin-util-test.py`. Use the `-v` option for verbose output. # Writing functional tests You are encouraged to write functional tests for new or existing features. -Further information about the functional test framework and individual +Further information about the functional test framework and individual tests is found in [test/functional](/test/functional).