diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/mining.cpp | 2 | ||||
-rw-r--r-- | src/rpc/util.cpp | 16 | ||||
-rw-r--r-- | src/test/test_bitcoin.cpp | 4 | ||||
-rw-r--r-- | src/test/test_bitcoin.h | 9 | ||||
-rw-r--r-- | src/test/validation_block_tests.cpp | 11 |
5 files changed, 25 insertions, 17 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 93fa3a2728..29684d0e6c 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -241,7 +241,7 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request) "Accepts the transaction into mined blocks at a higher (or lower) priority\n", { {"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id."}, - {"dummy", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "API-Compatibility for previous API. Must be zero or null.\n" + {"dummy", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "null", "API-Compatibility for previous API. Must be zero or null.\n" " DEPRECATED. For forward compatibility use named arguments and omit this parameter."}, {"fee_delta", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The fee value (in satoshis) to add (or subtract, if negative).\n" " Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n" diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 740f8351fe..b91baee4ac 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -258,20 +258,19 @@ std::string RPCHelpMan::ToString() const // Oneline summary ret += m_name; - bool is_optional{false}; + bool was_optional{false}; for (const auto& arg : m_args) { ret += " "; if (arg.m_optional) { - if (!is_optional) ret += "( "; - is_optional = true; + if (!was_optional) ret += "( "; + was_optional = true; } else { - // Currently we still support unnamed arguments, so any argument following an optional argument must also be optional - // If support for positional arguments is deprecated in the future, remove this line - assert(!is_optional); + if (was_optional) ret += ") "; + was_optional = false; } ret += arg.ToString(/* oneline */ true); } - if (is_optional) ret += " )"; + if (was_optional) ret += " )"; ret += "\n"; // Description @@ -285,8 +284,7 @@ std::string RPCHelpMan::ToString() const if (i == 0) ret += "\nArguments:\n"; // Push named argument name and description - const auto str_wrapper = (arg.m_type == RPCArg::Type::STR || arg.m_type == RPCArg::Type::STR_HEX) ? "\"" : ""; - sections.m_sections.emplace_back(std::to_string(i + 1) + ". " + str_wrapper + arg.m_name + str_wrapper, arg.ToDescriptionString()); + sections.m_sections.emplace_back(std::to_string(i + 1) + ". " + arg.m_name, arg.ToDescriptionString()); sections.m_max_pad = std::max(sections.m_max_pad, sections.m_sections.back().m_left.size()); // Recursively push nested args diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index bb8db9fa8d..a3201de385 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -22,6 +22,8 @@ const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr; +FastRandomContext g_insecure_rand_ctx; + void CConnmanTest::AddNode(CNode& node) { LOCK(g_connman->cs_vNodes); @@ -37,8 +39,6 @@ void CConnmanTest::ClearNodes() g_connman->vNodes.clear(); } -thread_local FastRandomContext g_insecure_rand_ctx; - std::ostream& operator<<(std::ostream& os, const uint256& num) { os << num.ToString(); diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h index 71c0379eac..31d90c0151 100644 --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -26,7 +26,14 @@ std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::os return stream << static_cast<typename std::underlying_type<T>::type>(e); } -thread_local extern FastRandomContext g_insecure_rand_ctx; +/** + * This global and the helpers that use it are not thread-safe. + * + * If thread-safety is needed, the global could be made thread_local (given + * that thread_local is supported on all architectures we support) or a + * per-thread instance could be used in the multi-threaded test. + */ +extern FastRandomContext g_insecure_rand_ctx; static inline void SeedInsecureRand(bool deterministic = false) { diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 7dd176b25d..62dfed6c41 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -152,12 +152,13 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering) // create a bunch of threads that repeatedly process a block generated above at random // this will create parallelism and randomness inside validation - the ValidationInterface // will subscribe to events generated during block validation and assert on ordering invariance - boost::thread_group threads; + std::vector<std::thread> threads; for (int i = 0; i < 10; i++) { - threads.create_thread([&blocks]() { + threads.emplace_back([&blocks]() { bool ignored; + FastRandomContext insecure; for (int i = 0; i < 1000; i++) { - auto block = blocks[InsecureRandRange(blocks.size() - 1)]; + auto block = blocks[insecure.randrange(blocks.size() - 1)]; ProcessNewBlock(Params(), block, true, &ignored); } @@ -171,7 +172,9 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering) }); } - threads.join_all(); + for (auto& t : threads) { + t.join(); + } while (GetMainSignals().CallbacksPending() > 0) { MilliSleep(100); } |