rippled
Loading...
Searching...
No Matches
acctdelete.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/acctdelete.h>
3
4#include <xrpl/protocol/jss.h>
5
6namespace ripple {
7namespace test {
8namespace jtx {
9
10// Delete account. If successful transfer remaining XRP to dest.
12acctdelete(jtx::Account const& account, jtx::Account const& dest)
13{
14 Json::Value jv;
15 jv[sfAccount.jsonName] = account.human();
16 jv[sfDestination.jsonName] = dest.human();
17 jv[sfTransactionType.jsonName] = jss::AccountDelete;
18 return jv;
19}
20
21// Close the ledger until the ledger sequence is large enough to close
22// the account. If margin is specified, close the ledger so `margin`
23// more closes are needed
24void
26{
27 using namespace jtx;
28 auto openLedgerSeq = [](jtx::Env& env) -> std::uint32_t {
29 return env.current()->seq();
30 };
31
32 int const delta = [&]() -> int {
33 if (env.seq(acc) + 255 > openLedgerSeq(env))
34 return env.seq(acc) - openLedgerSeq(env) + 255 - margin;
35 return 0;
36 }();
37 env.test.BEAST_EXPECT(margin == 0 || delta >= 0);
38 for (int i = 0; i < delta; ++i)
39 env.close();
40 env.test.BEAST_EXPECT(openLedgerSeq(env) == env.seq(acc) + 255 - margin);
41}
42
43} // namespace jtx
44} // namespace test
45} // namespace ripple
Represents a JSON value.
Definition json_value.h:130
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & human() const
Returns the human readable public key.
Definition Account.h:99
A transaction testing environment.
Definition Env.h:102
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:250
beast::unit_test::suite & test
Definition Env.h:104
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:312
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:103
void incLgrSeqForAccDel(jtx::Env &env, jtx::Account const &acc, std::uint32_t margin=0)
Json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6