Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1825: Remove InvalidHotWallet Error from gateway_balances RPC handler #1830

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/rpc/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ getErrorInfo(ClioError code)
{.code = ClioError::RpcMalformedRequest, .error = "malformedRequest", .message = "Malformed request."},
{.code = ClioError::RpcMalformedOwner, .error = "malformedOwner", .message = "Malformed owner."},
{.code = ClioError::RpcMalformedAddress, .error = "malformedAddress", .message = "Malformed address."},
{.code = ClioError::RpcInvalidHotWallet, .error = "invalidHotWallet", .message = "Invalid hot wallet."},
{.code = ClioError::RpcUnknownOption, .error = "unknownOption", .message = "Unknown option."},
{.code = ClioError::RpcFieldNotFoundTransaction,
.error = "fieldNotFoundTransaction",
Expand Down
1 change: 0 additions & 1 deletion src/rpc/Errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ enum class ClioError {
RpcMalformedRequest = 5001,
RpcMalformedOwner = 5002,
RpcMalformedAddress = 5003,
RpcInvalidHotWallet = 5004,
RpcUnknownOption = 5005,
RpcFieldNotFoundTransaction = 5006,
RpcMalformedOracleDocumentId = 5007,
Expand Down
4 changes: 0 additions & 4 deletions src/rpc/handlers/GatewayBalances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ GatewayBalancesHandler::process(GatewayBalancesHandler::Input input, Context con
if (auto status = std::get_if<Status>(&ret))
return Error{*status};

auto inHotbalances = [&](auto const& hw) { return output.hotBalances.contains(hw); };
if (not std::ranges::all_of(input.hotWallets, inHotbalances))
return Error{Status{ClioError::RpcInvalidHotWallet}};

output.accountID = input.account;
output.ledgerHash = ripple::strHex(lgrInfo.hash);
output.ledgerIndex = lgrInfo.seq;
Expand Down
1 change: 0 additions & 1 deletion src/web/impl/ErrorHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class ErrorHelper {
case rpc::ClioError::RpcMalformedRequest:
case rpc::ClioError::RpcMalformedOwner:
case rpc::ClioError::RpcMalformedAddress:
case rpc::ClioError::RpcInvalidHotWallet:
case rpc::ClioError::RpcFieldNotFoundTransaction:
case rpc::ClioError::RpcMalformedOracleDocumentId:
case rpc::ClioError::RpcMalformedAuthorizedCredentials:
Expand Down
1 change: 0 additions & 1 deletion src/web/ng/impl/ErrorHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ ErrorHelper::makeError(rpc::Status const& err) const
case rpc::ClioError::RpcMalformedRequest:
case rpc::ClioError::RpcMalformedOwner:
case rpc::ClioError::RpcMalformedAddress:
case rpc::ClioError::RpcInvalidHotWallet:
case rpc::ClioError::RpcFieldNotFoundTransaction:
case rpc::ClioError::RpcMalformedOracleDocumentId:
case rpc::ClioError::RpcMalformedAuthorizedCredentials:
Expand Down
47 changes: 0 additions & 47 deletions tests/unit/rpc/handlers/GatewayBalancesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,53 +327,6 @@ TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
});
}

TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
{
auto const seq = 300;

EXPECT_CALL(*backend_, fetchLedgerBySequence).Times(1);
// return valid ledgerHeader
auto const ledgerHeader = createLedgerHeader(kLEDGER_HASH, seq);
ON_CALL(*backend_, fetchLedgerBySequence(seq, _)).WillByDefault(Return(ledgerHeader));

// return valid account
auto const accountKk = ripple::keylet::account(getAccountIdWithString(kACCOUNT)).key;
ON_CALL(*backend_, doFetchLedgerObject(accountKk, seq, _)).WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));

// return valid owner dir
auto const ownerDir = createOwnerDirLedgerObject({ripple::uint256{kINDEX2}}, kINDEX1);
auto const ownerDirKk = ripple::keylet::ownerDir(getAccountIdWithString(kACCOUNT)).key;
ON_CALL(*backend_, doFetchLedgerObject(ownerDirKk, seq, _))
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
EXPECT_CALL(*backend_, doFetchLedgerObject).Times(2);

// create a valid line, balance is 0
auto const line1 = createRippleStateLedgerObject("USD", kISSUER, 0, kACCOUNT, 10, kACCOUNT2, 20, kTXN_ID, 123);
std::vector<Blob> bbs;
bbs.push_back(line1.getSerializer().peekData());
ON_CALL(*backend_, doFetchLedgerObjects).WillByDefault(Return(bbs));
EXPECT_CALL(*backend_, doFetchLedgerObjects).Times(1);

auto const handler = AnyHandler{GatewayBalancesHandler{backend_}};
runSpawn([&](auto yield) {
auto const output = handler.process(
json::parse(fmt::format(
R"({{
"account": "{}",
"hotwallet": "{}"
}})",
kACCOUNT,
kACCOUNT2
)),
Context{yield}
);
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "invalidHotWallet");
EXPECT_EQ(err.at("error_message").as_string(), "Invalid hot wallet.");
});
}

struct NormalTestBundle {
std::string testName;
ripple::STObject mockedDir;
Expand Down