Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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 @@ -126,7 +126,6 @@ getErrorInfo(ClioError code)
{.code = ClioError::RpcMalformedAuthorizedCredentials,
.error = "malformedAuthorizedCredentials",
.message = "Malformed authorized credentials."},
{.code = ClioError::RpcEntryNotFound, .error = "entryNotFound", .message = "Entry Not Found."},
// special system errors
{.code = ClioError::RpcInvalidApiVersion, .error = JS(invalid_API_version), .message = "Invalid API version."},
{.code = ClioError::RpcCommandIsMissing,
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/Errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ enum class ClioError {
RpcFieldNotFoundTransaction = 5006,
RpcMalformedOracleDocumentId = 5007,
RpcMalformedAuthorizedCredentials = 5008,
RpcEntryNotFound = 5009,
// NOTE: RpcEntryNotFound is replaced with RippledError::rpcENTRY_NOT_FOUND
// RpcEntryNotFound = 5009,

// special system errors start with 6000
RpcInvalidApiVersion = 6000,
Expand Down
8 changes: 4 additions & 4 deletions src/rpc/handlers/VaultInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ VaultInfoHandler::process(VaultInfoHandler::Input const& input, Context const& c
sharedPtrBackend_->fetchLedgerObject(accountKeylet.key, lgrInfo.seq, ctx.yield);

if (!accountLedgerObject)
return std::unexpected{Status{ClioError::RpcEntryNotFound}};
return std::unexpected{Status{RippledError::rpcENTRY_NOT_FOUND}};
}

return ripple::keylet::vault(*accountID, *input.tnxSequence);
Expand All @@ -116,7 +116,7 @@ VaultInfoHandler::process(VaultInfoHandler::Input const& input, Context const& c
if (nodeIndex.parseHex(*input.vaultID))
return ripple::keylet::vault(nodeIndex);

return std::unexpected{Status{ClioError::RpcEntryNotFound}};
return std::unexpected{Status{RippledError::rpcENTRY_NOT_FOUND}};
}();

if (not vaultKeylet.has_value())
Expand All @@ -127,7 +127,7 @@ VaultInfoHandler::process(VaultInfoHandler::Input const& input, Context const& c
sharedPtrBackend_->fetchLedgerObject(vaultKeylet.value().key, lgrInfo.seq, ctx.yield);

if (not vaultLedgerObject)
return Error{Status{ClioError::RpcEntryNotFound, "vault object not found."}};
return Error{Status{RippledError::rpcENTRY_NOT_FOUND, "vault object not found."}};

ripple::STLedgerEntry const vaultSle{
ripple::SerialIter{vaultLedgerObject->data(), vaultLedgerObject->size()}, vaultKeylet.value().key
Expand All @@ -137,7 +137,7 @@ VaultInfoHandler::process(VaultInfoHandler::Input const& input, Context const& c
auto const issuanceObject = sharedPtrBackend_->fetchLedgerObject(issuanceKeylet, lgrInfo.seq, ctx.yield);

if (not issuanceObject)
return Error{Status{ClioError::RpcEntryNotFound, "issuance object not found."}};
return Error{Status{RippledError::rpcENTRY_NOT_FOUND, "issuance object not found."}};

ripple::STLedgerEntry const issuanceSle{
ripple::SerialIter{issuanceObject->data(), issuanceObject->size()}, issuanceKeylet
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 @@ -91,7 +91,6 @@ class ErrorHelper {
case rpc::ClioError::RpcFieldNotFoundTransaction:
case rpc::ClioError::RpcMalformedOracleDocumentId:
case rpc::ClioError::RpcMalformedAuthorizedCredentials:
case rpc::ClioError::RpcEntryNotFound:
case rpc::ClioError::EtlConnectionError:
case rpc::ClioError::EtlRequestError:
case rpc::ClioError::EtlRequestTimeout:
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 @@ -105,7 +105,6 @@ ErrorHelper::makeError(rpc::Status const& err) const
case rpc::ClioError::RpcFieldNotFoundTransaction:
case rpc::ClioError::RpcMalformedOracleDocumentId:
case rpc::ClioError::RpcMalformedAuthorizedCredentials:
case rpc::ClioError::RpcEntryNotFound:
case rpc::ClioError::EtlConnectionError:
case rpc::ClioError::EtlRequestError:
case rpc::ClioError::EtlRequestTimeout:
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/rpc/handlers/VaultInfoTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct VaultInfoParamTestCaseBundle {
std::string testName;
std::string testJson;
std::string expectedError;
CombinedError expectedErrorCode;
std::string expectedErrorMessage;
};

Expand All @@ -86,6 +87,7 @@ generateTestValuesForParametersTest()
"idk": "idk"
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -94,6 +96,7 @@ generateTestValuesForParametersTest()
"seq": 4
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -102,6 +105,7 @@ generateTestValuesForParametersTest()
"owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -111,6 +115,7 @@ generateTestValuesForParametersTest()
"seq": "asdf"
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -120,6 +125,7 @@ generateTestValuesForParametersTest()
"seq": 3
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "OwnerNotHexString"
},
VaultInfoParamTestCaseBundle{
Expand All @@ -129,6 +135,7 @@ generateTestValuesForParametersTest()
"seq": 3
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "OwnerNotHexString"
},
VaultInfoParamTestCaseBundle{
Expand All @@ -137,6 +144,7 @@ generateTestValuesForParametersTest()
"vault_id": 3
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -145,6 +153,7 @@ generateTestValuesForParametersTest()
"vault_id": "idk"
})JSON",
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
},
VaultInfoParamTestCaseBundle{
Expand All @@ -158,6 +167,7 @@ generateTestValuesForParametersTest()
kACCOUNT
),
.expectedError = "malformedRequest",
.expectedErrorCode = ClioError::RpcMalformedRequest,
.expectedErrorMessage = "Malformed request."
}
};
Expand All @@ -181,6 +191,10 @@ TEST_P(VaultInfoParameterTest, InvalidParams)

auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
EXPECT_EQ(
err.at("error_code").as_uint64(),
std::visit([](auto code) { return static_cast<uint32_t>(code); }, testBundle.expectedErrorCode)
);
EXPECT_EQ(err.at("error_message").as_string(), testBundle.expectedErrorMessage);
});
}
Expand Down Expand Up @@ -208,6 +222,8 @@ TEST_F(RPCVaultInfoHandlerTest, InputHasOwnerButNotFoundResultsInError)
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "entryNotFound");
EXPECT_EQ(err.at("error_code").as_uint64(), rpc::RippledError::rpcENTRY_NOT_FOUND);
EXPECT_EQ(err.at("error_message").as_string(), "Entry not found.");
});
}

Expand Down Expand Up @@ -237,6 +253,8 @@ TEST_F(RPCVaultInfoHandlerTest, VaultIDFailsVaultDeserializationReturnsEntryNotF
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "entryNotFound");
EXPECT_EQ(err.at("error_code").as_uint64(), rpc::RippledError::rpcENTRY_NOT_FOUND);
EXPECT_EQ(err.at("error_message").as_string(), "vault object not found.");
});
}

Expand Down Expand Up @@ -277,6 +295,8 @@ TEST_F(RPCVaultInfoHandlerTest, MissingIssuanceObject)
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "entryNotFound");
EXPECT_EQ(err.at("error_code").as_uint64(), rpc::RippledError::rpcENTRY_NOT_FOUND);
EXPECT_EQ(err.at("error_message").as_string(), "issuance object not found.");
});
}

Expand Down