From e8c60d0676d55e3c8225f2ddc504a02704cf0f1e Mon Sep 17 00:00:00 2001 From: Fahrrader Date: Mon, 06 Dec 2021 15:22:10 +0000 Subject: [PATCH] test (confirmSponsorship): test CORE-239, make sure sponsor doesn't cover transfer fees for failed transactions --- --- a/tests/src/confirmSponsorship.test.ts +++ b/tests/src/confirmSponsorship.test.ts @@ -372,4 +372,31 @@ await destroyCollectionExpectSuccess(collectionId); await confirmSponsorshipExpectFailure(collectionId, '//Bob'); }); + + it('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async () => { + const collectionId = await createCollectionExpectSuccess(); + await setCollectionSponsorExpectSuccess(collectionId, bob.address); + await confirmSponsorshipExpectSuccess(collectionId, '//Bob'); + + await usingApi(async (api) => { + // Find unused address + const ownerZeroBalance = await findUnusedAddress(api); + + // Find another unused address + const senderZeroBalance = await findUnusedAddress(api); + + // Mint token for an unused address + const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', ownerZeroBalance.address); + + const sponsorBalanceBeforeTx = (await api.query.system.account(bob.address)).data.free.toBigInt(); + + // Try to transfer this token from an unsponsored unused adress to Alice + const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0); + await expect(submitTransactionExpectFailAsync(senderZeroBalance, zeroToAlice)).to.be.rejected; + + const sponsorBalanceAfterTx = (await api.query.system.account(bob.address)).data.free.toBigInt(); + + expect(sponsorBalanceAfterTx).to.equal(sponsorBalanceBeforeTx); + }); + }); }); -- gitstuff