-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: Merge bitcoin#228164, (partial) 28291, 28164, 27888, 28168, (partial) gui#771, gui#742 #7046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
backport: Merge bitcoin#228164, (partial) 28291, 28164, 27888, 28168, (partial) gui#771, gui#742 #7046
Changes from all commits
d097154
b85db6e
5987d2b
20af991
84e9409
66d405b
e141f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,43 +285,14 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values) | |
| BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001000000")), 1LL); //should pass, cut trailing 0 | ||
| BOOST_CHECK_THROW(AmountFromValue(ValueFromString("19e-9")), UniValue); //should fail | ||
| BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.19e-6")), 19); //should pass, leading 0 is present | ||
| BOOST_CHECK_EXCEPTION(AmountFromValue(".19e-6"), UniValue, HasJSON(R"({"code":-3,"message":"Invalid amount"})")); //should fail, no leading 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix compilation error: missing ValueFromString wrapper. The test passes a string literal 🔎 Proposed fix- BOOST_CHECK_EXCEPTION(AmountFromValue(".19e-6"), UniValue, HasJSON(R"({"code":-3,"message":"Invalid amount"})")); //should fail, no leading 0
+ BOOST_CHECK_EXCEPTION(AmountFromValue(ValueFromString(".19e-6")), UniValue, HasJSON(R"({"code":-3,"message":"Invalid amount"})")); //should fail, no leading 0🤖 Prompt for AI Agents |
||
|
|
||
| BOOST_CHECK_THROW(AmountFromValue(ValueFromString("92233720368.54775808")), UniValue); //overflow error | ||
| BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e+11")), UniValue); //overflow error | ||
| BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e11")), UniValue); //overflow error signless | ||
| BOOST_CHECK_THROW(AmountFromValue(ValueFromString("93e+9")), UniValue); //overflow error | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(json_parse_errors) | ||
| { | ||
| // Valid | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0").get_real(), 1.0); | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("true").get_bool(), true); | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("[false]")[0].get_bool(), false); | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("{\"a\": true}")["a"].get_bool(), true); | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("{\"1\": \"true\"}")["1"].get_str(), "true"); | ||
| // Valid, with leading or trailing whitespace | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue(" 1.0").get_real(), 1.0); | ||
| BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0 ").get_real(), 1.0); | ||
|
|
||
| BOOST_CHECK_THROW(AmountFromValue(ParseNonRFCJSONValue(".19e-6")), std::runtime_error); //should fail, missing leading 0, therefore invalid JSON | ||
| BOOST_CHECK_EQUAL(AmountFromValue(ParseNonRFCJSONValue("0.00000000000000000000000000000000000001e+30 ")), 1); | ||
| // Invalid, initial garbage | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("[1.0"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("a1.0"), std::runtime_error); | ||
| // Invalid, trailing garbage | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0sds"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0]"), std::runtime_error); | ||
| // Invalid, keys have to be names | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("{1: \"true\"}"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("{true: 1}"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("{[1]: 1}"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("{{\"a\": \"a\"}: 1}"), std::runtime_error); | ||
| // BTC addresses should fail parsing | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), std::runtime_error); | ||
| BOOST_CHECK_THROW(ParseNonRFCJSONValue("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), std::runtime_error); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(rpc_ban) | ||
| { | ||
| BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,13 +14,16 @@ | |
| #include <cstdio> | ||
| #include <cstdlib> | ||
|
|
||
|
|
||
| NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func) | ||
| : std::runtime_error{ | ||
| strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\n" | ||
| std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func) | ||
| { | ||
| return strprintf("Internal bug detected: %s\n%s:%d (%s)\n" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 28291: partial because it is depends on bitcoin#28123 |
||
| "%s %s\n" | ||
| "Please report this issue here: %s\n", | ||
| msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT)} | ||
| msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT); | ||
| } | ||
|
|
||
| NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func) | ||
| : std::runtime_error{StrFormatInternalBug(msg, file, line, func)} | ||
| { | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,12 +10,16 @@ | |
| #include <stdexcept> | ||
| #include <utility> | ||
|
|
||
| std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func); | ||
|
|
||
| class NonFatalCheckError : public std::runtime_error | ||
| { | ||
| public: | ||
| NonFatalCheckError(const char* msg, const char* file, int line, const char* func); | ||
| }; | ||
|
|
||
| #define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 26611: add this one 59e4354 |
||
| /** Helper for CHECK_NONFATAL() */ | ||
| template <typename T> | ||
| T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gui771: missing changes in
src/qt/walletcontroller.cpp, should be partial