mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 01:06:48 +00:00
fix template exception
This commit is contained in:
@@ -395,15 +395,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite
|
||||
using namespace test::jtx;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
Env env{*this, features};
|
||||
env.fund(XRP(1000), alice);
|
||||
env.fund(XRP(1000), alice, bob);
|
||||
env.close();
|
||||
|
||||
// We're going to hack the ledger in order to avoid generating
|
||||
// 4 billion or so NFTs. Because we're hacking the ledger we
|
||||
// need alice's account to have non-zero sfMintedNFTokens and
|
||||
// sfBurnedNFTokens fields. This prevents an exception when the
|
||||
// AccountRoot template is applied.
|
||||
// need alice's account to have non-zero sfMintedNFTokens,
|
||||
// sfBurnedNFTokens, sfSponsoredOwnerCount, sfSponsoringOwnerCount,
|
||||
// sfSponsoringAccountCount fields. This prevents an exception when
|
||||
// the AccountRoot template is applied.
|
||||
{
|
||||
uint256 const nftId0{token::getNextID(env, alice, 0u)};
|
||||
env(token::mint(alice, 0u));
|
||||
@@ -411,6 +413,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite
|
||||
|
||||
env(token::burn(alice, nftId0));
|
||||
env.close();
|
||||
|
||||
env(did::set(alice),
|
||||
did::uri("uri"),
|
||||
sponsor::as(bob, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, bob));
|
||||
env.close();
|
||||
|
||||
env(did::set(bob),
|
||||
did::uri("uri"),
|
||||
sponsor::as(alice, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, alice));
|
||||
env.close();
|
||||
|
||||
env(sponsor::transfer(bob),
|
||||
sponsor::as(alice, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, alice));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Note that we're bypassing almost all of the ledger's safety
|
||||
|
||||
@@ -399,8 +399,10 @@ public:
|
||||
env.close();
|
||||
|
||||
// Because we're hacking the ledger we need the account to have
|
||||
// non-zero sfMintedNFTokens and sfBurnedNFTokens fields. This
|
||||
// prevents an exception when the AccountRoot template is applied.
|
||||
// non-zero sfMintedNFTokens, sfBurnedNFTokens,
|
||||
// sfSponsoredOwnerCount, sfSponsoringOwnerCount,
|
||||
// sfSponsoringAccountCount fields. This prevents an exception when
|
||||
// the AccountRoot template is applied.
|
||||
{
|
||||
uint256 const nftId0{token::getNextID(env, gw, 0u)};
|
||||
env(token::mint(gw, 0u));
|
||||
@@ -408,6 +410,23 @@ public:
|
||||
|
||||
env(token::burn(gw, nftId0));
|
||||
env.close();
|
||||
|
||||
env(did::set(gw),
|
||||
did::uri("uri"),
|
||||
sponsor::as(alice, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, alice));
|
||||
env.close();
|
||||
|
||||
env(did::set(alice),
|
||||
did::uri("uri"),
|
||||
sponsor::as(gw, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, gw));
|
||||
env.close();
|
||||
|
||||
env(sponsor::transfer(alice),
|
||||
sponsor::as(gw, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, gw));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Note that we're bypassing almost all of the ledger's safety
|
||||
|
||||
@@ -297,7 +297,10 @@ SponsorshipTransfer::doApply()
|
||||
auto const newCount =
|
||||
ownerSle->getFieldU32(sfSponsoredOwnerCount) +
|
||||
ownerCountDelta;
|
||||
ownerSle->setFieldU32(sfSponsoredOwnerCount, newCount);
|
||||
if (newCount == 0)
|
||||
ownerSle->makeFieldAbsent(sfSponsoredOwnerCount);
|
||||
else
|
||||
ownerSle->setFieldU32(sfSponsoredOwnerCount, newCount);
|
||||
view().update(ownerSle);
|
||||
}
|
||||
// increment new sponsoring count
|
||||
|
||||
@@ -503,9 +503,10 @@ Transactor::payFee()
|
||||
|
||||
auto const feeAmountAfter = sle->getFieldAmount(result.field) - feePaid;
|
||||
|
||||
if (feeAmountAfter == beast::zero &&
|
||||
result.field.fieldMeta == SField::sMD_Default)
|
||||
// for ltSponsorship.sfFeeAmount
|
||||
if (feeAmountAfter == beast::zero && result.field == sfFeeAmount)
|
||||
// Because ltSponsorship.sfFeeAmount is soeDEFAULT
|
||||
// TODO: Use whether the field is soeDEFAULT instead of sfFeeAmount in
|
||||
// the condition.
|
||||
sle->makeFieldAbsent(result.field);
|
||||
else
|
||||
sle->setFieldAmount(result.field, feeAmountAfter);
|
||||
|
||||
Reference in New Issue
Block a user