66#include < rpc/server.h>
77#include < rpc/util.h>
88
9+ #include < amount.h>
910#include < core_io.h>
1011#include < interfaces/chain.h>
1112#include < node/context.h>
13+ #include < policy/feerate.h>
1214#include < test/util/setup_common.h>
1315#include < util/ref.h>
1416#include < util/time.h>
@@ -185,6 +187,7 @@ static UniValue ValueFromString(const std::string &str)
185187
186188BOOST_AUTO_TEST_CASE (rpc_parse_monetary_values)
187189{
190+ // Test AmountFromValue
188191 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" -0.00000001" )), UniValue);
189192 BOOST_CHECK_EQUAL (AmountFromValue (ValueFromString (" 0" )), 0LL );
190193 BOOST_CHECK_EQUAL (AmountFromValue (ValueFromString (" 0.00000000" )), 0LL );
@@ -206,6 +209,8 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
206209
207210 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 1e-9" )), UniValue); // should fail
208211 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 0.000000019" )), UniValue); // should fail
212+ BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 0.000999999" )), UniValue);
213+ BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 1.111111111" )), UniValue);
209214 BOOST_CHECK_EQUAL (AmountFromValue (ValueFromString (" 0.00000001000000" )), 1LL ); // should pass, cut trailing 0
210215 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 19e-9" )), UniValue); // should fail
211216 BOOST_CHECK_EQUAL (AmountFromValue (ValueFromString (" 0.19e-6" )), 19 ); // should pass, leading 0 is present
@@ -214,6 +219,15 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
214219 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 1e+11" )), UniValue); // overflow error
215220 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 1e11" )), UniValue); // overflow error signless
216221 BOOST_CHECK_THROW (AmountFromValue (ValueFromString (" 93e+9" )), UniValue); // overflow error
222+
223+ // Test FeeRateFromValueInSatB
224+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 0" )) == CFeeRate{0 });
225+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 0.00000000" )) == CFeeRate{0 });
226+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 0.001" )) == CFeeRate{1 });
227+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 0.00100000" )) == CFeeRate{1 });
228+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 1" )) == CFeeRate{1000 });
229+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 1.000" )) == CFeeRate{1000 });
230+ BOOST_CHECK (FeeRateFromValueInSatB (ValueFromString (" 1.2340000" )) == CFeeRate{1234 });
217231}
218232
219233BOOST_AUTO_TEST_CASE (json_parse_errors)
0 commit comments