hot wallet (#656)

Fix #654
This commit is contained in:
cyan317
2023-05-31 13:09:27 +01:00
committed by GitHub
parent 8ba7388d58
commit fc0c93b2ee
4 changed files with 5 additions and 4 deletions

View File

@@ -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))

View File

@@ -38,6 +38,7 @@ enum class ClioError {
rpcMALFORMED_REQUEST = 5001,
rpcMALFORMED_OWNER = 5002,
rpcMALFORMED_ADDRESS = 5003,
rpcINVALID_HOT_WALLET = 5004,
};
/**

View File

@@ -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);

View File

@@ -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.");
});
}