From fc0c93b2ee687ebfa8fc1b8a1a04fea3e7c547a7 Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Wed, 31 May 2023 13:09:27 +0100 Subject: [PATCH] hot wallet (#656) Fix #654 --- src/rpc/Errors.cpp | 2 +- src/rpc/Errors.h | 1 + src/rpc/handlers/GatewayBalances.cpp | 2 +- unittests/rpc/handlers/GatewayBalancesTest.cpp | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpc/Errors.cpp b/src/rpc/Errors.cpp index f487dc24..97c5fa6b 100644 --- a/src/rpc/Errors.cpp +++ b/src/rpc/Errors.cpp @@ -77,7 +77,7 @@ getErrorInfo(ClioError code) {ClioError::rpcMALFORMED_REQUEST, "malformedRequest", "Malformed request."}, {ClioError::rpcMALFORMED_OWNER, "malformedOwner", "Malformed owner."}, {ClioError::rpcMALFORMED_ADDRESS, "malformedAddress", "Malformed address."}, - }; + {ClioError::rpcINVALID_HOT_WALLET, "invalidHotWallet", "Invalid hot wallet."}}; auto matchByCode = [code](auto const& info) { return info.code == code; }; if (auto it = find_if(begin(infos), end(infos), matchByCode); it != end(infos)) diff --git a/src/rpc/Errors.h b/src/rpc/Errors.h index 99b7d49d..e06644eb 100644 --- a/src/rpc/Errors.h +++ b/src/rpc/Errors.h @@ -38,6 +38,7 @@ enum class ClioError { rpcMALFORMED_REQUEST = 5001, rpcMALFORMED_OWNER = 5002, rpcMALFORMED_ADDRESS = 5003, + rpcINVALID_HOT_WALLET = 5004, }; /** diff --git a/src/rpc/handlers/GatewayBalances.cpp b/src/rpc/handlers/GatewayBalances.cpp index 047274dd..a3aaf5f3 100644 --- a/src/rpc/handlers/GatewayBalances.cpp +++ b/src/rpc/handlers/GatewayBalances.cpp @@ -123,7 +123,7 @@ GatewayBalancesHandler::process(GatewayBalancesHandler::Input input, Context con auto inHotbalances = [&](auto const& hw) { return output.hotBalances.contains(hw); }; if (not std::all_of(input.hotWallets.begin(), input.hotWallets.end(), inHotbalances)) - return Error{Status{RippledError::rpcINVALID_PARAMS, "invalidHotWallet"}}; + return Error{Status{ClioError::rpcINVALID_HOT_WALLET}}; output.accountID = input.account; output.ledgerHash = ripple::strHex(lgrInfo.hash); diff --git a/unittests/rpc/handlers/GatewayBalancesTest.cpp b/unittests/rpc/handlers/GatewayBalancesTest.cpp index 687f641c..98753795 100644 --- a/unittests/rpc/handlers/GatewayBalancesTest.cpp +++ b/unittests/rpc/handlers/GatewayBalancesTest.cpp @@ -337,8 +337,8 @@ TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet) Context{std::ref(yield)}); ASSERT_FALSE(output); auto const err = RPC::makeError(output.error()); - EXPECT_EQ(err.at("error").as_string(), "invalidParams"); - EXPECT_EQ(err.at("error_message").as_string(), "invalidHotWallet"); + EXPECT_EQ(err.at("error").as_string(), "invalidHotWallet"); + EXPECT_EQ(err.at("error_message").as_string(), "Invalid hot wallet."); }); }