mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -48,10 +48,10 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
std::initializer_list<char const*> m)
|
||||
: index(idx), txType(t)
|
||||
{
|
||||
auto buildSet = [](auto&& init){
|
||||
auto buildSet = [](auto&& init) {
|
||||
boost::container::flat_set<std::string> r;
|
||||
r.reserve(init.size());
|
||||
for(auto&& s : init)
|
||||
for (auto&& s : init)
|
||||
r.insert(s);
|
||||
return r;
|
||||
};
|
||||
@@ -64,7 +64,7 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
|
||||
// A helper method tests can use to validate returned JSON vs NodeSanity.
|
||||
void
|
||||
checkSanity (Json::Value const& txNode, NodeSanity const& sane)
|
||||
checkSanity(Json::Value const& txNode, NodeSanity const& sane)
|
||||
{
|
||||
BEAST_EXPECT(txNode[jss::validated].asBool() == true);
|
||||
BEAST_EXPECT(
|
||||
@@ -77,26 +77,28 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
boost::container::flat_set<std::string> modifiedNodes;
|
||||
|
||||
for (Json::Value const& metaNode :
|
||||
txNode[jss::meta][sfAffectedNodes.jsonName])
|
||||
txNode[jss::meta][sfAffectedNodes.jsonName])
|
||||
{
|
||||
if (metaNode.isMember (sfCreatedNode.jsonName))
|
||||
createdNodes.insert (
|
||||
metaNode[sfCreatedNode.jsonName]
|
||||
[sfLedgerEntryType.jsonName].asString());
|
||||
if (metaNode.isMember(sfCreatedNode.jsonName))
|
||||
createdNodes.insert(
|
||||
metaNode[sfCreatedNode.jsonName][sfLedgerEntryType.jsonName]
|
||||
.asString());
|
||||
|
||||
else if (metaNode.isMember (sfDeletedNode.jsonName))
|
||||
deletedNodes.insert (
|
||||
metaNode[sfDeletedNode.jsonName]
|
||||
[sfLedgerEntryType.jsonName].asString());
|
||||
else if (metaNode.isMember(sfDeletedNode.jsonName))
|
||||
deletedNodes.insert(
|
||||
metaNode[sfDeletedNode.jsonName][sfLedgerEntryType.jsonName]
|
||||
.asString());
|
||||
|
||||
else if (metaNode.isMember (sfModifiedNode.jsonName))
|
||||
modifiedNodes.insert (
|
||||
metaNode[sfModifiedNode.jsonName]
|
||||
[sfLedgerEntryType.jsonName].asString());
|
||||
else if (metaNode.isMember(sfModifiedNode.jsonName))
|
||||
modifiedNodes.insert(metaNode[sfModifiedNode.jsonName]
|
||||
[sfLedgerEntryType.jsonName]
|
||||
.asString());
|
||||
|
||||
else
|
||||
fail ("Unexpected or unlabeled node type in metadata.",
|
||||
__FILE__, __LINE__);
|
||||
fail(
|
||||
"Unexpected or unlabeled node type in metadata.",
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
}
|
||||
|
||||
BEAST_EXPECT(createdNodes == sane.created);
|
||||
@@ -203,7 +205,7 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
p[jss::ledger_index_max] = env.closed()->info().seq;
|
||||
BEAST_EXPECT(hasTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index_max] = env.closed()->info().seq - 1 ;
|
||||
p[jss::ledger_index_max] = env.closed()->info().seq - 1;
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
}
|
||||
|
||||
@@ -224,8 +226,7 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
|
||||
p[jss::ledger_index] = env.current()->info().seq + 1;
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
rpcLGR_NOT_FOUND));
|
||||
env.rpc("json", "account_tx", to_string(p)), rpcLGR_NOT_FOUND));
|
||||
}
|
||||
|
||||
// Ledger Hash
|
||||
@@ -249,28 +250,28 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Env env(*this);
|
||||
Account const alice {"alice"};
|
||||
Account const alie {"alie"};
|
||||
Account const gw {"gw"};
|
||||
auto const USD {gw["USD"]};
|
||||
Account const alice{"alice"};
|
||||
Account const alie{"alie"};
|
||||
Account const gw{"gw"};
|
||||
auto const USD{gw["USD"]};
|
||||
|
||||
env.fund(XRP(1000000), alice, gw);
|
||||
env.close();
|
||||
|
||||
// AccountSet
|
||||
env (noop (alice));
|
||||
env(noop(alice));
|
||||
|
||||
// Payment
|
||||
env (pay (alice, gw, XRP (100)));
|
||||
env(pay(alice, gw, XRP(100)));
|
||||
|
||||
// Regular key set
|
||||
env (regkey(alice, alie));
|
||||
env(regkey(alice, alie));
|
||||
env.close();
|
||||
|
||||
// Trust and Offers
|
||||
env (trust (alice, USD (200)), sig (alie));
|
||||
std::uint32_t const offerSeq {env.seq(alice)};
|
||||
env (offer (alice, USD (50), XRP (150)), sig (alie));
|
||||
env(trust(alice, USD(200)), sig(alie));
|
||||
std::uint32_t const offerSeq{env.seq(alice)};
|
||||
env(offer(alice, USD(50), XRP(150)), sig(alie));
|
||||
env.close();
|
||||
|
||||
{
|
||||
@@ -278,19 +279,19 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
cancelOffer[jss::Account] = alice.human();
|
||||
cancelOffer[jss::OfferSequence] = offerSeq;
|
||||
cancelOffer[jss::TransactionType] = jss::OfferCancel;
|
||||
env (cancelOffer, sig (alie));
|
||||
env(cancelOffer, sig(alie));
|
||||
}
|
||||
env.close();
|
||||
|
||||
// SignerListSet
|
||||
env (signers (alice, 1, {{"bogie", 1}, {"demon", 1}}), sig (alie));
|
||||
env(signers(alice, 1, {{"bogie", 1}, {"demon", 1}}), sig(alie));
|
||||
|
||||
// Escrow
|
||||
{
|
||||
// Create an escrow. Requires either a CancelAfter or FinishAfter.
|
||||
auto escrow = [] (Account const& account,
|
||||
Account const& to, STAmount const& amount)
|
||||
{
|
||||
auto escrow = [](Account const& account,
|
||||
Account const& to,
|
||||
STAmount const& amount) {
|
||||
Json::Value escro;
|
||||
escro[jss::TransactionType] = jss::EscrowCreate;
|
||||
escro[jss::Flags] = tfUniversal;
|
||||
@@ -300,23 +301,23 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
return escro;
|
||||
};
|
||||
|
||||
NetClock::time_point const nextTime {env.now() + 2s};
|
||||
NetClock::time_point const nextTime{env.now() + 2s};
|
||||
|
||||
Json::Value escrowWithFinish {escrow (alice, alice, XRP (500))};
|
||||
Json::Value escrowWithFinish{escrow(alice, alice, XRP(500))};
|
||||
escrowWithFinish[sfFinishAfter.jsonName] =
|
||||
nextTime.time_since_epoch().count();
|
||||
|
||||
std::uint32_t const escrowFinishSeq {env.seq(alice)};
|
||||
env (escrowWithFinish, sig (alie));
|
||||
std::uint32_t const escrowFinishSeq{env.seq(alice)};
|
||||
env(escrowWithFinish, sig(alie));
|
||||
|
||||
Json::Value escrowWithCancel {escrow (alice, alice, XRP (500))};
|
||||
Json::Value escrowWithCancel{escrow(alice, alice, XRP(500))};
|
||||
escrowWithCancel[sfFinishAfter.jsonName] =
|
||||
nextTime.time_since_epoch().count();
|
||||
escrowWithCancel[sfCancelAfter.jsonName] =
|
||||
nextTime.time_since_epoch().count() + 1;
|
||||
|
||||
std::uint32_t const escrowCancelSeq {env.seq(alice)};
|
||||
env (escrowWithCancel, sig (alie));
|
||||
std::uint32_t const escrowCancelSeq{env.seq(alice)};
|
||||
env(escrowWithCancel, sig(alie));
|
||||
env.close();
|
||||
|
||||
{
|
||||
@@ -326,7 +327,7 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
escrowFinish[jss::Account] = alice.human();
|
||||
escrowFinish[sfOwner.jsonName] = alice.human();
|
||||
escrowFinish[sfOfferSequence.jsonName] = escrowFinishSeq;
|
||||
env (escrowFinish, sig (alie));
|
||||
env(escrowFinish, sig(alie));
|
||||
}
|
||||
{
|
||||
Json::Value escrowCancel;
|
||||
@@ -335,29 +336,29 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
escrowCancel[jss::Account] = alice.human();
|
||||
escrowCancel[sfOwner.jsonName] = alice.human();
|
||||
escrowCancel[sfOfferSequence.jsonName] = escrowCancelSeq;
|
||||
env (escrowCancel, sig (alie));
|
||||
env(escrowCancel, sig(alie));
|
||||
}
|
||||
env.close();
|
||||
}
|
||||
|
||||
// PayChan
|
||||
{
|
||||
std::uint32_t payChanSeq {env.seq (alice)};
|
||||
std::uint32_t payChanSeq{env.seq(alice)};
|
||||
Json::Value payChanCreate;
|
||||
payChanCreate[jss::TransactionType] = jss::PaymentChannelCreate;
|
||||
payChanCreate[jss::Flags] = tfUniversal;
|
||||
payChanCreate[jss::Account] = alice.human();
|
||||
payChanCreate[jss::Destination] = gw.human();
|
||||
payChanCreate[jss::Amount] =
|
||||
XRP (500).value().getJson (JsonOptions::none);
|
||||
XRP(500).value().getJson(JsonOptions::none);
|
||||
payChanCreate[sfSettleDelay.jsonName] =
|
||||
NetClock::duration{100s}.count();
|
||||
payChanCreate[sfPublicKey.jsonName] = strHex (alice.pk().slice());
|
||||
env (payChanCreate, sig (alie));
|
||||
payChanCreate[sfPublicKey.jsonName] = strHex(alice.pk().slice());
|
||||
env(payChanCreate, sig(alie));
|
||||
env.close();
|
||||
|
||||
std::string const payChanIndex {
|
||||
strHex (keylet::payChan (alice, gw, payChanSeq).key)};
|
||||
std::string const payChanIndex{
|
||||
strHex(keylet::payChan(alice, gw, payChanSeq).key)};
|
||||
|
||||
{
|
||||
Json::Value payChanFund;
|
||||
@@ -366,8 +367,8 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
payChanFund[jss::Account] = alice.human();
|
||||
payChanFund[sfPayChannel.jsonName] = payChanIndex;
|
||||
payChanFund[jss::Amount] =
|
||||
XRP (200).value().getJson (JsonOptions::none);
|
||||
env (payChanFund, sig (alie));
|
||||
XRP(200).value().getJson(JsonOptions::none);
|
||||
env(payChanFund, sig(alie));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
@@ -377,29 +378,27 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
payChanClaim[jss::Account] = gw.human();
|
||||
payChanClaim[sfPayChannel.jsonName] = payChanIndex;
|
||||
payChanClaim[sfPublicKey.jsonName] = strHex(alice.pk().slice());
|
||||
env (payChanClaim);
|
||||
env(payChanClaim);
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Check
|
||||
{
|
||||
uint256 const aliceCheckId {
|
||||
getCheckIndex (alice, env.seq (alice))};
|
||||
env (check::create (alice, gw, XRP (300)), sig (alie));
|
||||
uint256 const aliceCheckId{getCheckIndex(alice, env.seq(alice))};
|
||||
env(check::create(alice, gw, XRP(300)), sig(alie));
|
||||
|
||||
uint256 const gwCheckId {
|
||||
getCheckIndex (gw, env.seq (gw))};
|
||||
env (check::create (gw, alice, XRP (200)));
|
||||
uint256 const gwCheckId{getCheckIndex(gw, env.seq(gw))};
|
||||
env(check::create(gw, alice, XRP(200)));
|
||||
env.close();
|
||||
|
||||
env (check::cash (alice, gwCheckId, XRP (200)), sig (alie));
|
||||
env (check::cancel (alice, aliceCheckId), sig (alie));
|
||||
env(check::cash(alice, gwCheckId, XRP(200)), sig(alie));
|
||||
env(check::cancel(alice, aliceCheckId), sig(alie));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Deposit preauthorization.
|
||||
env (deposit::auth (alice, gw), sig (alie));
|
||||
env(deposit::auth(alice, gw), sig(alie));
|
||||
env.close();
|
||||
|
||||
// Setup is done. Look at the transactions returned by account_tx.
|
||||
@@ -408,49 +407,132 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
params[jss::ledger_index_min] = -1;
|
||||
params[jss::ledger_index_max] = -1;
|
||||
|
||||
Json::Value const result {
|
||||
Json::Value const result{
|
||||
env.rpc("json", "account_tx", to_string(params))};
|
||||
|
||||
BEAST_EXPECT (result[jss::result][jss::status] == "success");
|
||||
BEAST_EXPECT (result[jss::result][jss::transactions].isArray());
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == "success");
|
||||
BEAST_EXPECT(result[jss::result][jss::transactions].isArray());
|
||||
|
||||
Json::Value const& txs {result[jss::result][jss::transactions]};
|
||||
Json::Value const& txs{result[jss::result][jss::transactions]};
|
||||
|
||||
// Do a sanity check on each returned transaction. They should
|
||||
// be returned in the reverse order of application to the ledger.
|
||||
static const NodeSanity sanity[]
|
||||
{
|
||||
// txType, created, deleted, modified
|
||||
{ 0, jss::DepositPreauth, {jss::DepositPreauth}, {}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 1, jss::CheckCancel, {}, {jss::Check}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 2, jss::CheckCash, {}, {jss::Check}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 3, jss::CheckCreate, {jss::Check}, {}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 4, jss::CheckCreate, {jss::Check}, {}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 5, jss::PaymentChannelClaim, {}, {jss::PayChannel}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 6, jss::PaymentChannelFund, {}, {}, {jss::AccountRoot, jss::PayChannel }},
|
||||
{ 7, jss::PaymentChannelCreate, {jss::PayChannel}, {}, {jss::AccountRoot, jss::AccountRoot, jss::DirectoryNode, jss::DirectoryNode}},
|
||||
{ 8, jss::EscrowCancel, {}, {jss::Escrow}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 9, jss::EscrowFinish, {}, {jss::Escrow}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 10, jss::EscrowCreate, {jss::Escrow}, {}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 11, jss::EscrowCreate, {jss::Escrow}, {}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 12, jss::SignerListSet, {jss::SignerList}, {}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 13, jss::OfferCancel, {}, {jss::Offer, jss::DirectoryNode}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 14, jss::OfferCreate, {jss::Offer, jss::DirectoryNode}, {}, {jss::AccountRoot, jss::DirectoryNode}},
|
||||
{ 15, jss::TrustSet, {jss::RippleState, jss::DirectoryNode, jss::DirectoryNode}, {}, {jss::AccountRoot, jss::AccountRoot}},
|
||||
{ 16, jss::SetRegularKey, {}, {}, {jss::AccountRoot}},
|
||||
{ 17, jss::Payment, {}, {}, {jss::AccountRoot, jss::AccountRoot}},
|
||||
{ 18, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
{ 19, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
{ 20, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}},
|
||||
static const NodeSanity sanity[]{
|
||||
// txType, created, deleted, modified
|
||||
{0,
|
||||
jss::DepositPreauth,
|
||||
{jss::DepositPreauth},
|
||||
{},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{1,
|
||||
jss::CheckCancel,
|
||||
{},
|
||||
{jss::Check},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{2,
|
||||
jss::CheckCash,
|
||||
{},
|
||||
{jss::Check},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{3,
|
||||
jss::CheckCreate,
|
||||
{jss::Check},
|
||||
{},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{4,
|
||||
jss::CheckCreate,
|
||||
{jss::Check},
|
||||
{},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{5,
|
||||
jss::PaymentChannelClaim,
|
||||
{},
|
||||
{jss::PayChannel},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{6,
|
||||
jss::PaymentChannelFund,
|
||||
{},
|
||||
{},
|
||||
{jss::AccountRoot, jss::PayChannel}},
|
||||
{7,
|
||||
jss::PaymentChannelCreate,
|
||||
{jss::PayChannel},
|
||||
{},
|
||||
{jss::AccountRoot,
|
||||
jss::AccountRoot,
|
||||
jss::DirectoryNode,
|
||||
jss::DirectoryNode}},
|
||||
{8,
|
||||
jss::EscrowCancel,
|
||||
{},
|
||||
{jss::Escrow},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{9,
|
||||
jss::EscrowFinish,
|
||||
{},
|
||||
{jss::Escrow},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{10,
|
||||
jss::EscrowCreate,
|
||||
{jss::Escrow},
|
||||
{},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{11,
|
||||
jss::EscrowCreate,
|
||||
{jss::Escrow},
|
||||
{},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{12,
|
||||
jss::SignerListSet,
|
||||
{jss::SignerList},
|
||||
{},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{13,
|
||||
jss::OfferCancel,
|
||||
{},
|
||||
{jss::Offer, jss::DirectoryNode},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{14,
|
||||
jss::OfferCreate,
|
||||
{jss::Offer, jss::DirectoryNode},
|
||||
{},
|
||||
{jss::AccountRoot, jss::DirectoryNode}},
|
||||
{15,
|
||||
jss::TrustSet,
|
||||
{jss::RippleState, jss::DirectoryNode, jss::DirectoryNode},
|
||||
{},
|
||||
{jss::AccountRoot, jss::AccountRoot}},
|
||||
{16, jss::SetRegularKey, {}, {}, {jss::AccountRoot}},
|
||||
{17, jss::Payment, {}, {}, {jss::AccountRoot, jss::AccountRoot}},
|
||||
{18, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
{19, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
{20, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}},
|
||||
};
|
||||
|
||||
BEAST_EXPECT (std::extent<decltype (sanity)>::value ==
|
||||
BEAST_EXPECT(
|
||||
std::extent<decltype(sanity)>::value ==
|
||||
result[jss::result][jss::transactions].size());
|
||||
|
||||
for (unsigned int index {0};
|
||||
index < std::extent<decltype (sanity)>::value; ++index)
|
||||
for (unsigned int index{0};
|
||||
index < std::extent<decltype(sanity)>::value;
|
||||
++index)
|
||||
{
|
||||
checkSanity (txs[index], sanity[index]);
|
||||
checkSanity(txs[index], sanity[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,50 +546,50 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Env env(*this);
|
||||
Account const alice {"alice"};
|
||||
Account const becky {"becky"};
|
||||
Account const alice{"alice"};
|
||||
Account const becky{"becky"};
|
||||
|
||||
env.fund(XRP(10000), alice, becky);
|
||||
env.close();
|
||||
|
||||
// Verify that becky's account root is present.
|
||||
Keylet const beckyAcctKey {keylet::account (becky.id())};
|
||||
BEAST_EXPECT (env.closed()->exists (beckyAcctKey));
|
||||
Keylet const beckyAcctKey{keylet::account(becky.id())};
|
||||
BEAST_EXPECT(env.closed()->exists(beckyAcctKey));
|
||||
|
||||
// becky does an AccountSet .
|
||||
env (noop (becky));
|
||||
env(noop(becky));
|
||||
|
||||
// Close enough ledgers to be able to delete becky's account.
|
||||
std::uint32_t const ledgerCount {
|
||||
env.current()->seq() + 257 - env.seq (becky)};
|
||||
std::uint32_t const ledgerCount{
|
||||
env.current()->seq() + 257 - env.seq(becky)};
|
||||
|
||||
for (std::uint32_t i = 0; i < ledgerCount; ++i)
|
||||
env.close();
|
||||
|
||||
auto const beckyPreDelBalance {env.balance (becky)};
|
||||
auto const beckyPreDelBalance{env.balance(becky)};
|
||||
|
||||
auto const acctDelFee {drops (env.current()->fees().increment)};
|
||||
env (acctdelete (becky, alice), fee (acctDelFee));
|
||||
auto const acctDelFee{drops(env.current()->fees().increment)};
|
||||
env(acctdelete(becky, alice), fee(acctDelFee));
|
||||
env.close();
|
||||
|
||||
// Verify that becky's account root is gone.
|
||||
BEAST_EXPECT (! env.closed()->exists (beckyAcctKey));
|
||||
BEAST_EXPECT(!env.closed()->exists(beckyAcctKey));
|
||||
|
||||
// All it takes is a large enough XRP payment to resurrect
|
||||
// becky's account. Try too small a payment.
|
||||
env (pay (alice, becky, XRP (19)), ter (tecNO_DST_INSUF_XRP));
|
||||
env(pay(alice, becky, XRP(19)), ter(tecNO_DST_INSUF_XRP));
|
||||
env.close();
|
||||
|
||||
// Actually resurrect becky's account.
|
||||
env (pay (alice, becky, XRP (45)));
|
||||
env(pay(alice, becky, XRP(45)));
|
||||
env.close();
|
||||
|
||||
// becky's account root should be back.
|
||||
BEAST_EXPECT (env.closed()->exists (beckyAcctKey));
|
||||
BEAST_EXPECT (env.balance (becky) == XRP (45));
|
||||
BEAST_EXPECT(env.closed()->exists(beckyAcctKey));
|
||||
BEAST_EXPECT(env.balance(becky) == XRP(45));
|
||||
|
||||
// becky pays alice.
|
||||
env (pay (becky, alice, XRP(20)));
|
||||
env(pay(becky, alice, XRP(20)));
|
||||
env.close();
|
||||
|
||||
// Setup is done. Look at the transactions returned by account_tx.
|
||||
@@ -517,34 +599,41 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
params[jss::ledger_index_min] = -1;
|
||||
params[jss::ledger_index_max] = -1;
|
||||
|
||||
Json::Value const result {
|
||||
Json::Value const result{
|
||||
env.rpc("json", "account_tx", to_string(params))};
|
||||
|
||||
BEAST_EXPECT (result[jss::result][jss::status] == "success");
|
||||
BEAST_EXPECT (result[jss::result][jss::transactions].isArray());
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == "success");
|
||||
BEAST_EXPECT(result[jss::result][jss::transactions].isArray());
|
||||
|
||||
Json::Value const& txs {result[jss::result][jss::transactions]};
|
||||
Json::Value const& txs{result[jss::result][jss::transactions]};
|
||||
|
||||
// Do a sanity check on each returned transaction. They should
|
||||
// be returned in the reverse order of application to the ledger.
|
||||
static const NodeSanity sanity[]
|
||||
{
|
||||
// txType, created, deleted, modified
|
||||
/* becky pays alice */ { 0, jss::Payment, {}, {}, {jss::AccountRoot, jss::AccountRoot}},
|
||||
/* alice resurrects becky's acct */ { 1, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}},
|
||||
/* becky deletes her account */ { 2, jss::AccountDelete, {}, {jss::AccountRoot}, {jss::AccountRoot}},
|
||||
/* becky's noop */ { 3, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
/* "fund" sets flags */ { 4, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
/* "fund" creates becky's acct */ { 5, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}}
|
||||
};
|
||||
static const NodeSanity sanity[]{
|
||||
// txType, created, deleted,
|
||||
// modified
|
||||
/* becky pays alice */ {
|
||||
0, jss::Payment, {}, {}, {jss::AccountRoot, jss::AccountRoot}},
|
||||
/* alice resurrects becky's acct */
|
||||
{1, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}},
|
||||
/* becky deletes her account */
|
||||
{2, jss::AccountDelete, {}, {jss::AccountRoot}, {jss::AccountRoot}},
|
||||
/* becky's noop */
|
||||
{3, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
/* "fund" sets flags */
|
||||
{4, jss::AccountSet, {}, {}, {jss::AccountRoot}},
|
||||
/* "fund" creates becky's acct */
|
||||
{5, jss::Payment, {jss::AccountRoot}, {}, {jss::AccountRoot}}};
|
||||
|
||||
BEAST_EXPECT (std::extent<decltype (sanity)>::value ==
|
||||
BEAST_EXPECT(
|
||||
std::extent<decltype(sanity)>::value ==
|
||||
result[jss::result][jss::transactions].size());
|
||||
|
||||
for (unsigned int index {0};
|
||||
index < std::extent<decltype (sanity)>::value; ++index)
|
||||
for (unsigned int index{0};
|
||||
index < std::extent<decltype(sanity)>::value;
|
||||
++index)
|
||||
{
|
||||
checkSanity (txs[index], sanity[index]);
|
||||
checkSanity(txs[index], sanity[index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user