From af1697cc6a8074f8651a5e190147846cdf498c1c Mon Sep 17 00:00:00 2001 From: Edward Hennis Date: Wed, 3 Oct 2018 17:08:09 -0400 Subject: [PATCH] Improve RPC error message for fee command: * If rippled is not synced to the network, `fee` will return a "no network" error instead of the possibly confusing "not enabled" error. * Resolves RIPD-1588 --- src/ripple/rpc/handlers/Fee1.cpp | 1 + src/ripple/rpc/impl/Handler.cpp | 2 +- src/test/app/TxQ_test.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ripple/rpc/handlers/Fee1.cpp b/src/ripple/rpc/handlers/Fee1.cpp index 5090970d2..c5ed6135a 100644 --- a/src/ripple/rpc/handlers/Fee1.cpp +++ b/src/ripple/rpc/handlers/Fee1.cpp @@ -30,6 +30,7 @@ namespace ripple { // Bail if fee escalation is not enabled. auto const view = context.app.openLedger().current(); + BOOST_ASSERT(view); if (!view || !view->rules().enabled(featureFeeEscalation)) { RPC::inject_error(rpcNOT_ENABLED, context.params); diff --git a/src/ripple/rpc/impl/Handler.cpp b/src/ripple/rpc/impl/Handler.cpp index 5e7b22b54..b55e35d52 100644 --- a/src/ripple/rpc/impl/Handler.cpp +++ b/src/ripple/rpc/impl/Handler.cpp @@ -77,7 +77,7 @@ Handler const handlerArray[] { { "gateway_balances", byRef (&doGatewayBalances), Role::USER, NO_CONDITION }, { "get_counts", byRef (&doGetCounts), Role::ADMIN, NO_CONDITION }, { "feature", byRef (&doFeature), Role::ADMIN, NO_CONDITION }, - { "fee", byRef (&doFee), Role::USER, NO_CONDITION }, + { "fee", byRef (&doFee), Role::USER, NEEDS_CURRENT_LEDGER }, { "fetch_info", byRef (&doFetchInfo), Role::ADMIN, NO_CONDITION }, { "ledger_accept", byRef (&doLedgerAccept), Role::ADMIN, NEEDS_CURRENT_LEDGER }, { "ledger_cleaner", byRef (&doLedgerCleaner), Role::ADMIN, NEEDS_NETWORK_CONNECTION }, diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index d2786ed47..a24985f5e 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -1664,7 +1664,7 @@ public: auto fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result) && - !RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::contains_error(fee[jss::result])))) { auto const& result = fee[jss::result]; BEAST_EXPECT(result.isMember(jss::ledger_current_index) @@ -1692,7 +1692,7 @@ public: fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result) && - !RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::contains_error(fee[jss::result])))) { auto const& result = fee[jss::result]; BEAST_EXPECT(result.isMember(jss::ledger_current_index)