Skip to content

Commit c8e3b94

Browse files
committed
Merge bitcoin/bitcoin#29892: test: Fix failing univalue float test
fa4c696 test: Fix failing univalue float test (MarcoFalke) Pull request description: Currently the test may fail for some compilers, because `1e-8` may not be possible to represent exactly/consistently. ``` $ ./src/univalue/test/object object: univalue/test/object.cpp:424: void univalue_readwrite(): Assertion `v.read("0.00000000000000000000000000000000000001e+30 ") && v.get_real() == 1e-8' failed. Aborted (core dumped) ``` Fixes bitcoin/bitcoin#27256 (comment) ACKs for top commit: laanwj: ACK fa4c696 stickies-v: ACK fa4c696 , thanks for fixing! Tree-SHA512: dea4f4f843381d5e8ffaa812b2290a11e081b29f8777d041751c4aa9942e60f1f8d2d1a652d9a52b41dec470a490c9fe26ca9bc762dd593c3521b328a8af2826
2 parents 5c10d12 + fa4c696 commit c8e3b94

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/test/rpc_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
291291
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000);
292292
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000);
293293
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.01e-6")), COIN/100000000);
294+
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000000000000000000000000000000000001e+30")), 1);
294295
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000000000000000000000000000000000000000000000001e+68")), COIN/100000000);
295296
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("10000000000000000000000000000000000000000000000000000000000000000e-64")), COIN);
296297
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000e64")), COIN);

src/univalue/test/object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void univalue_readwrite()
421421
// Valid, with leading or trailing whitespace
422422
BOOST_CHECK(v.read(" 1.0") && (v.get_real() == 1.0));
423423
BOOST_CHECK(v.read("1.0 ") && (v.get_real() == 1.0));
424-
BOOST_CHECK(v.read("0.00000000000000000000000000000000000001e+30 ") && v.get_real() == 1e-8);
424+
BOOST_CHECK(v.read("0.00000000000000000000000000000000000001e+30 "));
425425

426426
BOOST_CHECK(!v.read(".19e-6")); //should fail, missing leading 0, therefore invalid JSON
427427
// Invalid, initial garbage

0 commit comments

Comments
 (0)