xrpld
Loading...
Searching...
No Matches
CredentialEntry.cpp
1#include <xrpl/ledger/entries/CredentialEntry.h>
2
3#include <xrpl/basics/Slice.h>
4#include <xrpl/protocol/Indexes.h>
5#include <xrpl/protocol/Keylet.h>
6
7#include <gtest/gtest.h>
8#include <ledger/EntryTestHelpers.h>
9
10#include <string>
11
12namespace xrpl::test {
13
14TEST(CredentialEntryTests, constructors)
15{
17
18 std::string const credTypeStr = "termsandconditions";
19 Slice const credType = makeSlice(credTypeStr);
20
22 e,
23 keylet::credential(e.alice.id(), e.bob.id(), credType),
24 "credential(subject, issuer, credType)",
25 e.alice.id(),
26 e.bob.id(),
27 credType);
28
30 e, keylet::credential(e.someID()), "credential(UInt256)", e.someID());
31
32 // Subject and issuer are both AccountIDs, so the assertion above only
33 // has teeth if their order matters.
34 EXPECT_NE(
35 keylet::credential(e.alice.id(), e.bob.id(), credType).key,
36 keylet::credential(e.bob.id(), e.alice.id(), credType).key);
37}
38
39} // namespace xrpl::test
An immutable linear range of bytes.
Definition Slice.h:28
Scaffolding shared by the per-entry-type suites.
UInt256 someID() const
An arbitrary but stable UInt256, for the entry constructors that take an object ID directly.
AccountID id() const
Returns the Account ID.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:585
TEST(UnitsTest, types)
Definition Units.cpp:16
void expectKeylet(EntryTestEnv &e, Keylet const &expected, std::string const &what, Args const &... args)
Assert that both flavors of Entry built from args resolve the ledger object that expected names.
Slice makeSlice(std::array< T, N > const &a)
Definition Slice.h:228