xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
tests
libxrpl
ledger
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
15
namespace
xrpl::test
{
16
17
TEST
(DepositPreauthEntryTests, constructors)
18
{
19
EntryTestEnv
e;
20
21
std::string
const
credTypeStr =
"termsandconditions"
;
22
std::set<std::pair<AccountID, Slice>
>
const
authCreds{{e.
bob
.
id
(),
makeSlice
(credTypeStr)}};
23
24
expectKeylet<DepositPreauthEntry>
(
25
e,
26
keylet::depositPreauth
(e.
alice
.
id
(), e.
bob
.
id
()),
27
"depositPreauth(owner, preauthorized)"
,
28
e.
alice
.
id
(),
29
e.
bob
.
id
());
30
31
expectKeylet<DepositPreauthEntry>
(
32
e,
33
keylet::depositPreauth
(e.
alice
.
id
(), authCreds),
34
"depositPreauth(owner, authCreds)"
,
35
e.
alice
.
id
(),
36
authCreds);
37
38
expectKeylet<DepositPreauthEntry>
(
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
std::string
xrpl::test::EntryTestEnv
Scaffolding shared by the per-entry-type suites.
Definition
EntryTestHelpers.h:28
xrpl::test::EntryTestEnv::alice
Account const alice
Definition
EntryTestHelpers.h:31
xrpl::test::EntryTestEnv::someID
UInt256 someID() const
An arbitrary but stable UInt256, for the entry constructors that take an object ID directly.
Definition
EntryTestHelpers.h:62
xrpl::test::EntryTestEnv::bob
Account const bob
Definition
EntryTestHelpers.h:32
xrpl::test::jtx::Account::id
AccountID id() const
Returns the Account ID.
Definition
jtx/Account.h:104
xrpl::keylet::depositPreauth
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition
Indexes.cpp:374
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::test::TEST
TEST(UnitsTest, types)
Definition
Units.cpp:16
xrpl::test::expectKeylet
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.
Definition
EntryTestHelpers.h:96
xrpl::makeSlice
Slice makeSlice(std::array< T, N > const &a)
Definition
Slice.h:228
set
string
utility
Generated by
1.17.0