From 30c2d9db48ab552a3deef2df504fd973200756da Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 8 Jun 2017 09:43:54 +0200 Subject: [PATCH 1/3] [tests] Remove unused function InsecureRandBytes(size_t len) --- src/test/test_bitcoin.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h index 0087eeb2d..c9e4a3427 100644 --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -33,7 +33,6 @@ static inline uint256 InsecureRand256() { return insecure_rand_ctx.rand256(); } static inline uint64_t InsecureRandBits(int bits) { return insecure_rand_ctx.randbits(bits); } static inline uint64_t InsecureRandRange(uint64_t range) { return insecure_rand_ctx.randrange(range); } static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); } -static inline std::vector InsecureRandBytes(size_t len) { return insecure_rand_ctx.randbytes(len); } /** Basic testing setup. * This just configures logging and chain parameters. From 9f841a6c3d8ebc6a84ac646604eebcdb9d6763ef Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 8 Jun 2017 09:44:32 +0200 Subject: [PATCH 2/3] [tests] Remove accidental trailing semicolon --- test/functional/replace-by-fee.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/replace-by-fee.py b/test/functional/replace-by-fee.py index ca7b623ca..d6bf3ea59 100755 --- a/test/functional/replace-by-fee.py +++ b/test/functional/replace-by-fee.py @@ -521,7 +521,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): def test_rpc(self): us0 = self.nodes[0].listunspent()[0] - ins = [us0]; + ins = [us0] outs = {self.nodes[0].getnewaddress() : Decimal(1.0000000)} rawtx0 = self.nodes[0].createrawtransaction(ins, outs, 0, True) rawtx1 = self.nodes[0].createrawtransaction(ins, outs, 0, False) From 67ca816849d0aa292a138e6c08edafd17ad6a948 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 8 Jun 2017 12:06:09 +0200 Subject: [PATCH 3/3] Simplify "bool x = y ? true : false" to "bool x = y" --- src/blockencodings.cpp | 2 +- src/rpc/misc.cpp | 4 ++-- src/test/miner_tests.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index ee2c65498..9cac10d2b 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -172,7 +172,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const { assert(!header.IsNull()); assert(index < txn_available.size()); - return txn_available[index] ? true : false; + return txn_available[index] != nullptr; } ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector& vtx_missing) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 1f973a0c1..76aa7ec99 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -212,8 +212,8 @@ UniValue validateaddress(const JSONRPCRequest& request) #ifdef ENABLE_WALLET isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; - ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); - ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); + ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE))); + ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY))); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest); ret.pushKVs(detail); if (pwallet && pwallet->mapAddressBook.count(dest)) { diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index c95800a72..eaff2ac70 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { tx.vout[0].nValue -= LOWFEE; hash = tx.GetHash(); - bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase + bool spendsCoinbase = i == 0; // only first tx spends coinbase // If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { tx.vout[0].nValue -= LOWFEE; hash = tx.GetHash(); - bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase + bool spendsCoinbase = i == 0; // only first tx spends coinbase // If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx)); tx.vin[0].prevout.hash = hash; @@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { tx.vout[0].nValue -= LOWFEE; hash = tx.GetHash(); - bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase + bool spendsCoinbase = i == 0; // only first tx spends coinbase mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; }