Skip to content

Commit

Permalink
clang
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Oct 16, 2023
1 parent 095bdec commit 60db95e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ NFTokenAcceptOffer::acceptOffer(std::shared_ptr<SLE> const& offer)
//
// But, this isn't a problem when a buy offer is involved, because a buy
// offer is already taking up reserve. Since the buy offer is deleted
// near the end of the transaction, its reserve will be freed up, and at the same time,
// the new NFT that the buyer bought could take up that reserve again. So it's
// guareenteed that there is enough reserve as long the transactor pass the
// preclaim.
// near the end of the transaction, its reserve will be freed up, and at the
// same time, the new NFT that the buyer bought could take up that reserve
// again. So it's guareenteed that there is enough reserve as long the
// transactor pass the preclaim.
if (view().rules().enabled(fixNFTokenReserve))
{
if (auto const ret = checkBuyerReserve(sleBuyer, buyerOwnerCountBefore);
Expand Down Expand Up @@ -502,10 +502,10 @@ NFTokenAcceptOffer::doApply()
// if fixNFTokenReserve is enabled, check if the buyer has sufficient
// reserve to own a new object, if their OwnerCount changed.
//
// However, this check is merely for safety and should never trigger,
// because, in brokered mode, the buy offer's reserve will be freed up,
// which can be taken up by the new NFT again. So buyer is always guarenteed
// to have enough reserve.
// However, this check is merely for safety and should never trigger,
// because, in brokered mode, the buy offer's reserve will be freed up,
// which can be taken up by the new NFT again. So buyer is always
// guarenteed to have enough reserve.
if (view().rules().enabled(fixNFTokenReserve))
{
if (auto const ret =
Expand Down
21 changes: 13 additions & 8 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7018,7 +7018,8 @@ class NFToken0_test : public beast::unit_test::suite
env.close();

// Bob is funded with account reserve + increment reserve + 1 XRP
// increment reserve is for the buy offer, and 1 XRP is for offer price
// increment reserve is for the buy offer, and 1 XRP is for offer
// price
env.fund(acctReserve + incReserve + XRP(1), bob);
env.close();

Expand All @@ -7033,8 +7034,9 @@ class NFToken0_test : public beast::unit_test::suite
env(token::createOffer(bob, nftId, XRP(1)), token::owner(alice));
env.close();

// accepting the buy offer fails because bob's balance is 10 drops lower
// than the required amount, since the previous tx burnt 10 drops for tx fee.
// accepting the buy offer fails because bob's balance is 10 drops
// lower than the required amount, since the previous tx burnt 10
// drops for tx fee.
env(token::acceptBuyOffer(alice, buyOfferIndex),
ter(tecINSUFFICIENT_FUNDS));
env.close();
Expand Down Expand Up @@ -7065,11 +7067,12 @@ class NFToken0_test : public beast::unit_test::suite
env.fund(XRP(10000), alice, broker);
env.close();

// Bob is funded with account reserve + incr reserve + 1 XRP(offer price)
// Bob is funded with account reserve + incr reserve + 1 XRP(offer
// price)
env.fund(acctReserve + incReserve + XRP(1), bob);
env.close();

// Alice mints a NFT
// Alice mints a NFT
uint256 const nftId{
token::getNextID(env, alice, 0u, tfTransferable)};
env(token::mint(alice, 0u), txflags(tfTransferable));
Expand All @@ -7090,10 +7093,12 @@ class NFToken0_test : public beast::unit_test::suite
env.close();

// broker offers.
// Returns insufficient funds, because bob burnt tx fee when he created his buy offer,
// which makes his spendable balance to be less than the required amount.
// Returns insufficient funds, because bob burnt tx fee when he
// created his buy offer, which makes his spendable balance to be
// less than the required amount.
env(token::brokerOffers(
broker, offerBobToBroker, offerAliceToBroker), ter(tecINSUFFICIENT_FUNDS));
broker, offerBobToBroker, offerAliceToBroker),
ter(tecINSUFFICIENT_FUNDS));
env.close();

// send Bob 10 drops
Expand Down

0 comments on commit 60db95e

Please sign in to comment.