mirror of
https://github.com/ZmnSCPxj/clboss.git
synced 2026-08-13 12:33:20 +02:00
Large amounts in the XRebalancer / XMoveFunds log lines were unbroken digit runs (delivered 18851040 msat); grep-heavy log sessions kept miscounting them. Add Util::Str::group_digits, which renders an integer with an underscore every three digit places (18_851_040), matching the digit grouping clboss-xrebalance-view and the other contrib tools already print. Applied to the amounts that get large: - XRebalancer cycle line (derived N, request) - XRebalancer transfer-done line (delivered, fee) - XMoveFunds planning line (amount, maxfee) - XMoveFunds 204 summary and fee-picture diagnostics (alloc_fee, required_out) - XMoveFunds per-part budget refusals (would deliver) - format_route_fees per-hop table (in/out/fee) Counts, ppm values, and cltv deltas stay plain. Signed overload handles the int64 call sites (INT64_MIN-safe). New tests/util/test_str covers both overloads and the boundary cases.
25 lines
758 B
C++
25 lines
758 B
C++
#undef NDEBUG
|
|
#include"Util/Str.hpp"
|
|
#include<assert.h>
|
|
#include<cstdint>
|
|
|
|
int main() {
|
|
using Util::Str::group_digits;
|
|
|
|
/* Unsigned. */
|
|
assert(group_digits(std::uint64_t(0)) == "0");
|
|
assert(group_digits(std::uint64_t(999)) == "999");
|
|
assert(group_digits(std::uint64_t(1000)) == "1_000");
|
|
assert(group_digits(std::uint64_t(18851040)) == "18_851_040");
|
|
assert(group_digits(std::uint64_t(220708066)) == "220_708_066");
|
|
assert( group_digits(std::uint64_t(18446744073709551615ull))
|
|
== "18_446_744_073_709_551_615");
|
|
|
|
/* Signed. */
|
|
assert(group_digits(std::int64_t(-1)) == "-1");
|
|
assert(group_digits(std::int64_t(-18851040)) == "-18_851_040");
|
|
assert( group_digits(std::int64_t(INT64_MIN))
|
|
== "-9_223_372_036_854_775_808");
|
|
|
|
return 0;
|
|
}
|