git.delta.rocks / unique-network / refs/commits / 6ec7415afe21

difftreelog

test fix refungible test

Yaroslav Bolyukin2021-11-19parent: #f09c318.patch.diff
in: master

1 file changed

modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
251 const zeroBalance = await findUnusedAddress(api);251 const zeroBalance = await findUnusedAddress(api);
252252
253 // Mint token for alice253 // Mint token for alice
254 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);254 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);
255255
256 // Transfer this token from Alice to unused address and back
257 // Alice to Zero gets sponsored
258 const aliceToZero = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);256 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);
257
258 // Zero to alice gets sponsored
259 const events1 = await submitTransactionAsync(alice, aliceToZero);259 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
260 const result1 = getGenericResult(events1);260 const result1 = getGenericResult(events1);
261 expect(result1.success).to.be.true;261 expect(result1.success).to.be.true;
262262
263 // Second transfer should fail263 // Second transfer should fail
264 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();264 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
265 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);
266 const badTransaction = async function () {
267 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
268 };
269 await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');265 await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejectedWith('Inability to pay some fees');
270 const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();266 const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
267 expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
271268
272 // Try again after Zero gets some balance - now it should succeed269 // Try again after Zero gets some balance - now it should succeed
273 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);270 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
276 const result2 = getGenericResult(events2);273 const result2 = getGenericResult(events2);
277 expect(result2.success).to.be.true;274 expect(result2.success).to.be.true;
278
279 expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
280 });275 });
281 });276 });
282277