diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -380,7 +380,9 @@ // Ensure that for all addrs in addrman, isTerrible == false. addr.nTime = GetAdjustedTime(); addrman.Add(addr, ResolveIP(strAddr)); - if (i % 8 == 0) addrman.Good(addr); + if (i % 8 == 0) { + addrman.Good(addr); + } } std::vector vAddr = addrman.GetAddr(); diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp --- a/src/test/allocator_tests.cpp +++ b/src/test/allocator_tests.cpp @@ -77,38 +77,45 @@ b.walk(); #endif // Sweeping allocate all memory - for (int x = 0; x < 1024; ++x) + for (int x = 0; x < 1024; ++x) { addr.push_back(b.alloc(1024)); + } BOOST_CHECK(b.stats().free == 0); // memory is full, this must return nullptr BOOST_CHECK(b.alloc(1024) == nullptr); BOOST_CHECK(b.alloc(0) == nullptr); - for (int x = 0; x < 1024; ++x) + for (int x = 0; x < 1024; ++x) { b.free(addr[x]); + } addr.clear(); BOOST_CHECK(b.stats().total == synth_size); BOOST_CHECK(b.stats().free == synth_size); // Now in the other direction... - for (int x = 0; x < 1024; ++x) + for (int x = 0; x < 1024; ++x) { addr.push_back(b.alloc(1024)); - for (int x = 0; x < 1024; ++x) + } + for (int x = 0; x < 1024; ++x) { b.free(addr[1023 - x]); + } addr.clear(); // Now allocate in smaller unequal chunks, then deallocate haphazardly // Not all the chunks will succeed allocating, but freeing nullptr is // allowed so that is no problem. - for (int x = 0; x < 2048; ++x) + for (int x = 0; x < 2048; ++x) { addr.push_back(b.alloc(x + 1)); - for (int x = 0; x < 2048; ++x) + } + for (int x = 0; x < 2048; ++x) { b.free(addr[((x * 23) % 2048) ^ 242]); + } addr.clear(); // Go entirely wild: free and alloc interleaved, generate targets and sizes // using pseudo-randomness. - for (int x = 0; x < 2048; ++x) + for (int x = 0; x < 2048; ++x) { addr.push_back(0); + } uint32_t s = 0x12345678; for (int x = 0; x < 5000; ++x) { int idx = s & (addr.size() - 1); @@ -121,10 +128,13 @@ bool lsb = s & 1; s >>= 1; // LFSR period 0xf7ffffe0 - if (lsb) s ^= 0xf00f00f0; + if (lsb) { + s ^= 0xf00f00f0; + } } - for (void *ptr : addr) + for (void *ptr : addr) { b.free(ptr); + } addr.clear(); BOOST_CHECK(b.stats().total == synth_size); diff --git a/src/test/arith_uint256_tests.cpp b/src/test/arith_uint256_tests.cpp --- a/src/test/arith_uint256_tests.cpp +++ b/src/test/arith_uint256_tests.cpp @@ -236,8 +236,9 @@ BOOST_CHECK(-ZeroL == ZeroL); BOOST_CHECK(-R1L == (~R1L) + 1); - for (unsigned int i = 0; i < 256; ++i) + for (unsigned int i = 0; i < 256; ++i) { BOOST_CHECK(-(OneL << i) == (MaxL << i)); + } } // Check if doing _A_ _OP_ _B_ results in the same as applying _OP_ onto each @@ -461,9 +462,10 @@ BOOST_CHECK((OneL << i).getdouble() == ldexp(1.0, i)); } BOOST_CHECK(ZeroL.getdouble() == 0.0); - for (int i = 256; i > 53; --i) + for (int i = 256; i > 53; --i) { BOOST_CHECK( almostEqual((R1L >> (256 - i)).getdouble(), ldexp(R1Ldouble, i))); + } uint64_t R1L64part = (R1L >> 192).GetLow64(); for (int i = 53; i > 0; --i) // doubles can store all integers in {0,...,2^54-1} exactly diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -1120,7 +1120,9 @@ // when we've inserted one minus an integer multiple of nElement*2. unsigned int nHits = 0; for (int i = 0; i < 10000; i++) { - if (rb1.contains(RandomData())) ++nHits; + if (rb1.contains(RandomData())) { + ++nHits; + } } // Expect about 100 hits BOOST_CHECK_EQUAL(nHits, 75); @@ -1132,7 +1134,9 @@ // Now roll through data, make sure last 100 entries // are always remembered: for (int i = 0; i < DATASIZE; i++) { - if (i >= 100) BOOST_CHECK(rb1.contains(data[i - 100])); + if (i >= 100) { + BOOST_CHECK(rb1.contains(data[i - 100])); + } rb1.insert(data[i]); BOOST_CHECK(rb1.contains(data[i])); } @@ -1146,7 +1150,9 @@ // Sanity check to make sure the filter isn't just filling up: nHits = 0; for (int i = 0; i < DATASIZE; i++) { - if (rb1.contains(data[i])) ++nHits; + if (rb1.contains(data[i])) { + ++nHits; + } } // Expect about 5 false positives BOOST_CHECK_EQUAL(nHits, 6); diff --git a/src/test/cashaddrenc_tests.cpp b/src/test/cashaddrenc_tests.cpp --- a/src/test/cashaddrenc_tests.cpp +++ b/src/test/cashaddrenc_tests.cpp @@ -128,7 +128,9 @@ for (auto net : GetNetworks()) { for (auto otherNet : GetNetworks()) { - if (net == otherNet) continue; + if (net == otherNet) { + continue; + } const auto netParams = CreateChainParams(net); std::string encoded = EncodeCashAddr(dst, *netParams); diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp --- a/src/test/checkqueue_tests.cpp +++ b/src/test/checkqueue_tests.cpp @@ -181,8 +181,9 @@ range.reserve(100000 / 1000); for (size_t i = 2; i < 100000; i += std::max((size_t)1, (size_t)InsecureRandRange(std::min( - (size_t)1000, ((size_t)100000) - i)))) + (size_t)1000, ((size_t)100000) - i)))) { range.push_back(i); + } Correct_Queue_range(range); } @@ -204,8 +205,9 @@ std::vector vChecks; vChecks.reserve(r); - for (size_t k = 0; k < r && remaining; k++, remaining--) + for (size_t k = 0; k < r && remaining; k++, remaining--) { vChecks.emplace_back(remaining == 1); + } control.Add(vChecks); } bool success = control.Wait(); @@ -263,15 +265,17 @@ while (total) { size_t r = InsecureRandRange(10); std::vector vChecks; - for (size_t k = 0; k < r && total; k++) + for (size_t k = 0; k < r && total; k++) { vChecks.emplace_back(--total); + } control.Add(vChecks); } } bool r = true; BOOST_REQUIRE_EQUAL(UniqueCheck::results.size(), COUNT); - for (size_t i = 0; i < COUNT; ++i) + for (size_t i = 0; i < COUNT; ++i) { r = r && UniqueCheck::results.count(i) == 1; + } BOOST_REQUIRE(r); tg.interrupt_all(); tg.join_all(); diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp --- a/src/test/cuckoocache_tests.cpp +++ b/src/test/cuckoocache_tests.cpp @@ -310,7 +310,7 @@ */ std::vector threads; /** Erase the first quarter */ - for (uint32_t x = 0; x < 3; ++x) + for (uint32_t x = 0; x < 3; ++x) { /** Each thread is emplaced with x copy-by-value */ threads.emplace_back([&, x] { boost::shared_lock l(mtx); @@ -321,6 +321,7 @@ set.contains(hashes[i], true); } }); + } /** Wait for all threads to finish */ for (std::thread &t : threads) { diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -17,8 +17,9 @@ static bool is_null_key(const std::vector &key) { bool isnull = true; - for (unsigned int i = 0; i < key.size(); i++) + for (unsigned int i = 0; i < key.size(); i++) { isnull &= (key[i] == '\x00'); + } return isnull; } @@ -234,7 +235,9 @@ BOOST_CHECK(it->Valid()); // Avoid spurious errors about invalid iterator's key and value in // case of failure - if (!it->Valid()) break; + if (!it->Valid()) { + break; + } BOOST_CHECK(it->GetKey(key)); if (x & 1) { BOOST_CHECK_EQUAL(key, x + 1); @@ -280,8 +283,9 @@ } } } else { - for (size_t i = 0; i < str.size(); i++) + for (size_t i = 0; i < str.size(); i++) { READWRITE(str[i]); + } } } }; @@ -295,8 +299,9 @@ for (int y = 0; y < 10; y++) { snprintf(buf, sizeof(buf), "%d", x); StringContentsSerializer key(buf); - for (int z = 0; z < y; z++) + for (int z = 0; z < y; z++) { key += key; + } uint32_t value = x * x; BOOST_CHECK(dbw.Write(key, value)); } @@ -312,14 +317,17 @@ for (int y = 0; y < 10; y++) { snprintf(buf, sizeof(buf), "%d", x); std::string exp_key(buf); - for (int z = 0; z < y; z++) + for (int z = 0; z < y; z++) { exp_key += exp_key; + } StringContentsSerializer key; uint32_t value; BOOST_CHECK(it->Valid()); // Avoid spurious errors about invalid iterator's key and value // in case of failure - if (!it->Valid()) break; + if (!it->Valid()) { + break; + } BOOST_CHECK(it->GetKey(key)); BOOST_CHECK(it->GetValue(value)); BOOST_CHECK_EQUAL(key.str, exp_key); diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -454,8 +454,9 @@ SignSignature(keystore, *txPrev, tx, 0, SigHashType()); // Re-use same signature for other inputs // (they don't have to be valid for this test) - for (unsigned int j = 1; j < tx.vin.size(); j++) + for (unsigned int j = 1; j < tx.vin.size(); j++) { tx.vin[j].scriptSig = tx.vin[0].scriptSig; + } BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i)); } diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -16,9 +16,10 @@ static void ResetArgs(ArgsManager &am, const std::string &strArg) { std::vector vecArg; - if (strArg.size()) + if (strArg.size()) { boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on); + } // Insert dummy executable name: vecArg.insert(vecArg.begin(), "testbitcoin"); diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -772,8 +772,9 @@ BOOST_CHECK(pool.exists(tx6.GetId())); BOOST_CHECK(!pool.exists(tx7.GetId())); - if (!pool.exists(tx5.GetId())) + if (!pool.exists(tx5.GetId())) { pool.addUnchecked(entry.Fee(1000 * SATOSHI).FromTx(tx5)); + } pool.addUnchecked(entry.Fee(9000 * SATOSHI).FromTx(tx7)); // should maximize mempool size by only removing 5/7 diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -37,10 +37,16 @@ uint256 *proot, bool *pmutated, uint32_t branchpos, std::vector *pbranch) { - if (pbranch) pbranch->clear(); + if (pbranch) { + pbranch->clear(); + } if (leaves.size() == 0) { - if (pmutated) *pmutated = false; - if (proot) *proot = uint256(); + if (pmutated) { + *pmutated = false; + } + if (proot) { + *proot = uint256(); + } return; } bool mutated = false; @@ -128,8 +134,12 @@ } } // Return result. - if (pmutated) *pmutated = mutated; - if (proot) *proot = h; + if (pmutated) { + *pmutated = mutated; + } + if (proot) { + *proot = h; + } } static std::vector @@ -156,8 +166,9 @@ // Safe upper bound for the number of total nodes. vMerkleTree.reserve(block.vtx.size() * 2 + 16); for (std::vector::const_iterator it(block.vtx.begin()); - it != block.vtx.end(); ++it) + it != block.vtx.end(); ++it) { vMerkleTree.push_back((*it)->GetId()); + } int j = 0; bool mutated = false; for (int nSize = block.vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { @@ -197,7 +208,9 @@ } static inline int ctz(uint32_t i) { - if (i == 0) return 0; + if (i == 0) { + return 0; + } int j = 0; while (!(i & 1)) { j++; @@ -225,11 +238,15 @@ int ntx1 = ntx + duplicate1; // Likewise for the second mutation. int duplicate2 = mutate >= 2 ? 1 << ctz(ntx1) : 0; - if (duplicate2 >= ntx1) break; + if (duplicate2 >= ntx1) { + break; + } int ntx2 = ntx1 + duplicate2; // And for the third mutation. int duplicate3 = mutate >= 3 ? 1 << ctz(ntx2) : 0; - if (duplicate3 >= ntx2) break; + if (duplicate3 >= ntx2) { + break; + } int ntx3 = ntx2 + duplicate3; // Build a block with ntx different transactions. CBlock block; diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -49,8 +49,9 @@ // calculate actual merkle root and height uint256 merkleRoot1 = BlockMerkleRoot(block); std::vector vTxid(nTx, uint256()); - for (unsigned int j = 0; j < nTx; j++) + for (unsigned int j = 0; j < nTx; j++) { vTxid[j] = block.vtx[j]->GetId(); + } int nHeight = 1, nTx_ = nTx; while (nTx_ > 1) { nTx_ = (nTx_ + 1) / 2; @@ -66,7 +67,9 @@ for (unsigned int j = 0; j < nTx; j++) { bool fInclude = InsecureRandBits(att / 2) == 0; vMatch[j] = fInclude; - if (fInclude) vMatchTxid1.push_back(vTxid[j]); + if (fInclude) { + vMatchTxid1.push_back(vTxid[j]); + } } // build the partial merkle tree diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp --- a/src/test/raii_event_tests.cpp +++ b/src/test/raii_event_tests.cpp @@ -25,7 +25,9 @@ static void *tag_malloc(size_t sz) { void *mem = malloc(sz); - if (!mem) return mem; + if (!mem) { + return mem; + } tags[mem]++; orders[mem] = tagSequence++; return mem; diff --git a/src/test/scriptflags.cpp b/src/test/scriptflags.cpp --- a/src/test/scriptflags.cpp +++ b/src/test/scriptflags.cpp @@ -46,8 +46,9 @@ boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); for (std::string &word : words) { - if (!mapFlagNames.count(word)) + if (!mapFlagNames.count(word)) { BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); + } flags |= mapFlagNames[word]; } diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -91,8 +91,9 @@ const CScriptNum scriptnum(num); // -INT64_MIN is undefined - if (num != std::numeric_limits::min()) + if (num != std::numeric_limits::min()) { BOOST_CHECK(verify(-bignum, -scriptnum)); + } } static void CheckSubtract(const int64_t &num1, const int64_t &num2) {