git.delta.rocks / unique-network / refs/commits / e8c60d0676d5

difftreelog

test (confirmSponsorship): test CORE-239, make sure sponsor doesn't cover transfer fees for failed transactions

Fahrrader2021-12-06parent: #6d5ea17.patch.diff
in: master

1 file changed

modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
373 await confirmSponsorshipExpectFailure(collectionId, '//Bob');373 await confirmSponsorshipExpectFailure(collectionId, '//Bob');
374 });374 });
375
376 it('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async () => {
377 const collectionId = await createCollectionExpectSuccess();
378 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
379 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
380
381 await usingApi(async (api) => {
382 // Find unused address
383 const ownerZeroBalance = await findUnusedAddress(api);
384
385 // Find another unused address
386 const senderZeroBalance = await findUnusedAddress(api);
387
388 // Mint token for an unused address
389 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', ownerZeroBalance.address);
390
391 const sponsorBalanceBeforeTx = (await api.query.system.account(bob.address)).data.free.toBigInt();
392
393 // Try to transfer this token from an unsponsored unused adress to Alice
394 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);
395 await expect(submitTransactionExpectFailAsync(senderZeroBalance, zeroToAlice)).to.be.rejected;
396
397 const sponsorBalanceAfterTx = (await api.query.system.account(bob.address)).data.free.toBigInt();
398
399 expect(sponsorBalanceAfterTx).to.equal(sponsorBalanceBeforeTx);
400 });
401 });
375});402});
376403