Skip to content

Commit

Permalink
Rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oleks-rip committed Nov 7, 2024
1 parent b78eef9 commit 6371e3b
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 138 deletions.
246 changes: 139 additions & 107 deletions src/test/app/PermissionedDomains_test.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/test/jtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <test/jtx/Env.h>
#include <test/jtx/Env_ss.h>
#include <test/jtx/JTx.h>
#include <test/jtx/PermissionedDomains.h>
#include <test/jtx/TestHelpers.h>
#include <test/jtx/account_txn_id.h>
#include <test/jtx/acctdelete.h>
Expand All @@ -51,6 +50,7 @@
#include <test/jtx/owners.h>
#include <test/jtx/paths.h>
#include <test/jtx/pay.h>
#include <test/jtx/permissioned_domains.h>
#include <test/jtx/prop.h>
#include <test/jtx/quality.h>
#include <test/jtx/rate.h>
Expand Down
6 changes: 3 additions & 3 deletions src/test/jtx/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ hash_append(Hasher& h, Account const& v) noexcept
hash_append(h, v.id());
}

inline bool
operator<(Account const& lhs, Account const& rhs) noexcept
inline auto
operator<=>(Account const& lhs, Account const& rhs) noexcept
{
return lhs.id() < rhs.id();
return lhs.id() <=> rhs.id();
}

} // namespace jtx
Expand Down
3 changes: 3 additions & 0 deletions src/test/jtx/deposit.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct AuthorizeCredentials
jtx::Account issuer;
std::string credType;

auto
operator<=>(const AuthorizeCredentials&) const = default;

Json::Value
toJson() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
//==============================================================================

#include <test/jtx/PermissionedDomains.h>
#include <test/jtx/permissioned_domains.h>
#include <exception>

namespace ripple {
Expand All @@ -42,12 +42,8 @@ setTx(
for (auto const& credential : credentials)
{
Json::Value obj(Json::objectValue);
obj[sfIssuer.jsonName] = to_string(credential.first);
obj[sfCredentialType.jsonName] =
strHex(Slice{credential.second.data(), credential.second.size()});
Json::Value o2(Json::objectValue);
o2[sfAcceptedCredential.jsonName] = obj;
a.append(o2);
obj[sfCredential.jsonName] = credential.toJson();
a.append(std::move(obj));
}
jv[sfAcceptedCredentials.jsonName] = a;
return jv;
Expand Down Expand Up @@ -105,20 +101,23 @@ objectExists(uint256 const& objID, Env& env)

// Extract credentials from account_object object
Credentials
credentialsFromJson(Json::Value const& object)
credentialsFromJson(
Json::Value const& object,
std::unordered_map<std::string, Account> const& pubKey2Acc)
{
Credentials ret;
Json::Value a(Json::arrayValue);
a = object["AcceptedCredentials"];
for (auto const& credential : a)
{
Json::Value obj(Json::objectValue);
obj = credential["AcceptedCredential"];
auto const& issuer = obj["Issuer"];
obj = credential[jss::Credential];
auto const& issuer = obj[jss::Issuer];
auto const& credentialType = obj["CredentialType"];
ret.emplace_back(
*parseBase58<AccountID>(issuer.asString()),
strUnHex(credentialType.asString()).value());
auto blob = strUnHex(credentialType.asString()).value();
ret.push_back(
{pubKey2Acc.at(issuer.asString()),
std::string(blob.begin(), blob.end())});
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
*/
//==============================================================================

#ifndef RIPPLE_TEST_JTX_PERMISSIONEDDOMAINS_H_INCLUDED
#define RIPPLE_TEST_JTX_PERMISSIONEDDOMAINS_H_INCLUDED
#pragma once

#include <test/jtx.h>
#include <test/jtx/deposit.h>

namespace ripple {
namespace test {
namespace jtx {
namespace pd {

// Helpers for PermissionedDomains testing
using Credential = std::pair<AccountID, Blob>;
using Credential = ripple::test::jtx::deposit::AuthorizeCredentials;
using Credentials = std::vector<Credential>;

// helpers
Expand All @@ -51,16 +51,11 @@ getObjects(Account const& account, Env& env, bool withType = true);
bool
objectExists(uint256 const& objID, Env& env);

// Convert string to Blob
inline Blob
toBlob(std::string const& input)
{
return Blob(input.begin(), input.end());
}

// Extract credentials from account_object object
Credentials
credentialsFromJson(Json::Value const& object);
credentialsFromJson(
Json::Value const& object,
std::unordered_map<std::string, Account> const& pubKey2Acc);

// Sort credentials the same way as PermissionedDomainSet
Credentials
Expand All @@ -78,5 +73,3 @@ getNewDomain(std::shared_ptr<STObject const> const& meta);
} // namespace jtx
} // namespace test
} // namespace ripple

#endif // RIPPLE_TEST_JTX_PERMISSIONEDDOMAINS_H_INCLUDED
2 changes: 1 addition & 1 deletion src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2944,7 +2944,7 @@ class LedgerRPC_test : public beast::unit_test::suite
env.close();

auto const seq = env.seq(alice);
env(pd::setTx(alice, {{alice, pd::toBlob("first credential")}}));
env(pd::setTx(alice, {{alice, "first credential"}}));
env.close();
auto const objects = pd::getObjects(alice, env);
BEAST_EXPECT(objects.size() == 1);
Expand Down

0 comments on commit 6371e3b

Please sign in to comment.