xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
jtx
impl
acctdelete.cpp
1
#include <test/jtx/acctdelete.h>
2
3
#include <test/jtx/Account.h>
4
#include <test/jtx/Env.h>
5
6
#include <xrpl/beast/unit_test/suite.h>
7
#include <xrpl/json/json_value.h>
8
#include <xrpl/protocol/SField.h>
9
#include <xrpl/protocol/jss.h>
10
11
#include <
cstdint
>
12
13
namespace
xrpl::test::jtx
{
14
15
// Delete account. If successful transfer remaining XRP to dest.
16
json::Value
17
acctdelete
(
jtx::Account
const
& account,
jtx::Account
const
& dest)
18
{
19
json::Value
jv;
20
jv[sfAccount.jsonName] = account.human();
21
jv[sfDestination.jsonName] = dest.
human
();
22
jv[sfTransactionType.jsonName] = jss::AccountDelete;
23
return
jv;
24
}
25
26
// Close the ledger until the ledger sequence is large enough to close
27
// the account. If margin is specified, close the ledger so `margin`
28
// more closes are needed
29
void
30
incLgrSeqForAccDel
(
jtx::Env
& env,
jtx::Account
const
& acc,
std::uint32_t
margin)
31
{
32
using namespace
jtx
;
33
auto
openLedgerSeq = [](
jtx::Env
& env) ->
std::uint32_t
{
return
env.
current
()->seq(); };
34
35
int
const
delta = [&]() ->
int
{
36
if
(env.
seq
(acc) + 255 > openLedgerSeq(env))
37
return
env.
seq
(acc) - openLedgerSeq(env) + 255 - margin;
38
return
0;
39
}();
40
env.
test
.BEAST_EXPECT(margin == 0 || delta >= 0);
41
for
(
int
i = 0; i < delta; ++i)
42
env.
close
();
43
env.
test
.BEAST_EXPECT(openLedgerSeq(env) == env.
seq
(acc) + 255 - margin);
44
}
45
46
}
// namespace xrpl::test::jtx
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:21
xrpl::test::jtx::Account::human
std::string const & human() const
Returns the human readable public key.
Definition
jtx/Account.h:113
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::close
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition
Env.cpp:133
xrpl::test::jtx::Env::seq
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition
Env.cpp:302
xrpl::test::jtx::Env::test
beast::unit_test::Suite & test
Definition
Env.h:163
xrpl::test::jtx::Env::current
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition
Env.h:377
cstdint
std::uint32_t
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::acctdelete
json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
Definition
acctdelete.cpp:17
xrpl::test::jtx::incLgrSeqForAccDel
void incLgrSeqForAccDel(jtx::Env &env, jtx::Account const &acc, std::uint32_t margin=0)
Definition
acctdelete.cpp:30
Generated by
1.17.0