diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index bf12d97f3..10b4a4d55 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -679,14 +679,11 @@ Json::Value checkFee ( feeTrack.scaleFeeLoad (feeDefault, ledger->fees().base, ledger->fees().units, isUnlimited (role)); std::uint64_t fee = loadFee; - if (ledger->rules().enabled(featureFeeEscalation, - config.features)) { auto const assumeTx = request.isMember("x-assume-tx") && request["x-assume-tx"].isConvertibleTo(Json::uintValue) ? request["x-assume-tx"].asUInt() : 0; auto const metrics = txQ.getMetrics(config, *ledger, assumeTx); - assert(metrics); if(metrics) { auto const baseFee = ledger->fees().base; @@ -709,7 +706,7 @@ Json::Value checkFee ( request["x-queue-okay"].isBool() && request["x-queue-okay"].asBool()) { - fee = loadFee; + fee = std::max(loadFee, limit); } if (fee > limit) { @@ -719,7 +716,7 @@ Json::Value checkFee ( return RPC::make_error (rpcHIGH_FEE, ss.str()); } - tx [jss::Fee] = static_cast(fee); + tx [jss::Fee] = static_cast(fee); return Json::Value(); } diff --git a/src/ripple/rpc/tests/JSONRPC.test.cpp b/src/ripple/rpc/tests/JSONRPC.test.cpp index 177735a82..b5b3ef747 100644 --- a/src/ripple/rpc/tests/JSONRPC.test.cpp +++ b/src/ripple/rpc/tests/JSONRPC.test.cpp @@ -1932,28 +1932,27 @@ public: } } - static - std::unique_ptr - makeConfig() - { - auto p = std::make_unique(); - test::setupConfigForUnitTests(*p); - auto& section = p->section("transaction_queue"); - section.set("minimum_txn_in_ledger_standalone", "3"); - return p; - } - void testAutoFillEscalatedFees () { - test::jtx::Env env(*this, makeConfig(), + test::jtx::Env env(*this, []() + { + auto p = std::make_unique(); + test::setupConfigForUnitTests(*p); + auto& section = p->section("transaction_queue"); + section.set("minimum_txn_in_ledger_standalone", "3"); + return p; + }(), test::jtx::features(featureFeeEscalation)); LoadFeeTrack const& feeTrack = env.app().getFeeTrack(); { // 1: high mult, no queue, no pad Json::Value req; - Json::Reader ().parse ( - "{ \"fee_mult_max\" : 1000, \"tx_json\" : { } } ", req); + Json::Reader ().parse (R"({ + "fee_mult_max" : 1000, + "x-queue-okay" : false, + "tx_json" : { } + })", req); Json::Value result = checkFee (req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -1967,8 +1966,11 @@ public: { // 2: high mult, can queue, no pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 1000, \"x-queue-okay\" : true \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 1000, + "x-queue-okay" : true, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -1982,8 +1984,11 @@ public: { // 3: high mult, no queue, 4 pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 1000, \"x-assume-tx\" : 4, \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 1000, + "x-assume-tx" : 4, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -1997,8 +2002,12 @@ public: { // 4: high mult, can queue, 4 pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 1000, \"x-assume-tx\" : 4, \"x-queue-okay\" : true \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 1000, + "x-assume-tx" : 4, + "x-queue-okay" : true, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -2013,8 +2022,10 @@ public: { // 5: low mult, no queue, no pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 5, \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 5, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -2028,8 +2039,11 @@ public: { // 6: low mult, can queue, no pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 5, \"x-queue-okay\" : true \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 5, + "x-queue-okay" : true, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -2043,8 +2057,12 @@ public: { // 7: low mult, no queue, 4 pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 5, \"x-assume-tx\" : 4, \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 5, + "x-assume-tx" : 4, + "x-queue-okay" : false, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -2057,8 +2075,12 @@ public: { // 8: : low mult, can queue, 4 pad Json::Value req; - Json::Reader().parse( - "{ \"fee_mult_max\" : 5, \"x-assume-tx\" : 4, \"x-queue-okay\" : true \"tx_json\" : { } } ", req); + Json::Reader().parse(R"({ + "fee_mult_max" : 5, + "x-assume-tx" : 4, + "x-queue-okay" : true, + "tx_json" : { } + })", req); Json::Value result = checkFee(req, Role::ADMIN, true, env.app().config(), feeTrack, @@ -2066,7 +2088,27 @@ public: expect(!RPC::contains_error(result), "Legal checkFee"); expect(req[jss::tx_json].isMember(jss::Fee) && - req[jss::tx_json][jss::Fee] == 10); + req[jss::tx_json][jss::Fee] == 50); + } + + { + // 8a: : different low mult, can queue, 4 pad + Json::Value req; + Json::Reader().parse(R"({ + "fee_mult_max" : 1000, + "fee_div_max" : 3, + "x-assume-tx" : 4, + "x-queue-okay" : true, + "tx_json" : { } + })", req); + Json::Value result = + checkFee(req, Role::ADMIN, true, + env.app().config(), feeTrack, + env.app().getTxQ(), env.current()); + + expect(!RPC::contains_error(result), "Legal checkFee"); + expect(req[jss::tx_json].isMember(jss::Fee) && + req[jss::tx_json][jss::Fee] == 3333); } }