Skip to content

Commit

Permalink
new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Nov 23, 2022
1 parent 2a67d23 commit c5eb27f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/test/app/NFTokenBurn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,53 @@ class NFTokenBurn_test : public beast::unit_test::suite
BEAST_EXPECT(ownerCount(env, becky) == 0);
}

// Test that up to 499 buy/sell offers will be removed when NFT is burned
// after fixUnburnableNFToken is enabled.
// This is to test that we can successfully remove all offers
// if the number of offers is less than 500.
{
Env env{*this, features | fixUnburnableNFToken};

Account const alice("alice");
env.fund(XRP(1000), alice);
env.close();

// We create 498 buy offers and 1 sell offers.
// When the token is burned, all of the 498 buy offers should be removed, and the sell offers is removed.
// In total, 499 offers are removed
std::vector<uint256> offerIndexes;
auto const nftokenID = createNftAndOffers(env, alice, offerIndexes, maxDeletableTokenOfferEntries - 2);

// Verify all offers are present in the ledger.
for (uint256 const& offerIndex : offerIndexes)
{
BEAST_EXPECT(env.le(keylet::nftoffer(offerIndex)));
}

// Create sell offer
uint256 const aliceOfferIndex =
keylet::nftoffer(alice, env.seq(alice)).key;
env(token::createOffer(alice, nftokenID, drops(1)),
txflags(tfSellNFToken));
env.close();

env(token::burn(alice, nftokenID));
env.close();

// Burning the token should remove all 498 buy-offers from the ledger.
for (uint256 const& offerIndex : offerIndexes)
{
BEAST_EXPECT(!env.le(keylet::nftoffer(offerIndex)));
}

// Burning the token should also remove the 499th offer that alice created
// And leave out the additional sell offer
BEAST_EXPECT(!env.le(keylet::nftoffer(aliceOfferIndex)));

// alice should have ownerCounts of one.
BEAST_EXPECT(ownerCount(env, alice) == 0);
}

// Test that up to 500 buy offers are removed when NFT is burned
// after fixUnburnableNFToken is enabled
{
Expand Down

0 comments on commit c5eb27f

Please sign in to comment.