xrpld
Loading...
Searching...
No Matches
DepositPreauthEntry.cpp
1#include <xrpl/ledger/entries/DepositPreauthEntry.h>
2
3#include <xrpl/basics/Slice.h>
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/Indexes.h>
6#include <xrpl/protocol/Keylet.h>
7
8#include <gtest/gtest.h>
9#include <ledger/EntryTestHelpers.h>
10
11#include <set>
12#include <string>
13#include <utility>
14
15namespace xrpl::test {
16
17TEST(DepositPreauthEntryTests, constructors)
18{
20
21 std::string const credTypeStr = "termsandconditions";
22 std::set<std::pair<AccountID, Slice>> const authCreds{{e.bob.id(), makeSlice(credTypeStr)}};
23
25 e,
27 "depositPreauth(owner, preauthorized)",
28 e.alice.id(),
29 e.bob.id());
30
32 e,
33 keylet::depositPreauth(e.alice.id(), authCreds),
34 "depositPreauth(owner, authCreds)",
35 e.alice.id(),
36 authCreds);
37
39 e, keylet::depositPreauth(e.someID()), "depositPreauth(UInt256)", e.someID());
40
41 // Owner and preauthorized are both AccountIDs, so the assertion above
42 // only has teeth if their order matters.
43 EXPECT_NE(
44 keylet::depositPreauth(e.alice.id(), e.bob.id()).key,
45 keylet::depositPreauth(e.bob.id(), e.alice.id()).key);
46
47 // The credential-set overload must not collide with the single-account
48 // one.
49 EXPECT_NE(
50 keylet::depositPreauth(e.alice.id(), authCreds).key,
51 keylet::depositPreauth(e.alice.id(), e.bob.id()).key);
52}
53
54} // namespace xrpl::test
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 depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:374
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