difftreelog
fix(scheduler) comment sponsorship tests, remove .only
in: master
1 file changed
tests/src/.outdated/scheduler.test.tsdiffbeforeafterboth30 enablePublicMintingExpectSuccess,30 enablePublicMintingExpectSuccess,31 addToAllowListExpectSuccess,31 addToAllowListExpectSuccess,32 waitNewBlocks,32 waitNewBlocks,33 makeScheduledId,34 normalizeAccountId,33 normalizeAccountId,35 getTokenOwner,34 getTokenOwner,36 getGenericResult,35 getGenericResult,410 expect(priorityChanged!.event.data[2].toString()).to.be.equal(priority.toString());409 expect(priorityChanged!.event.data[2].toString()).to.be.equal(priority.toString());411 });410 });412411413 itSub.ifWithPallets.only('Prioritized operations executes in valid order', [Pallets.Scheduler], async ({helper}) => {412 itSub.ifWithPallets('Prioritized operations executes in valid order', [Pallets.Scheduler], async ({helper}) => {414 const [413 const [415 scheduledFirstId,414 scheduledFirstId,416 scheduledSecondId,415 scheduledSecondId,579 });578 });580579581 it('Can sponsor scheduling a transaction', async () => {580 it('Can sponsor scheduling a transaction', async () => {582 const collectionId = await createCollectionExpectSuccess();581 // const collectionId = await createCollectionExpectSuccess();583 await setCollectionSponsorExpectSuccess(collectionId, bob.address);582 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);584 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');583 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');585584586 await usingApi(async api => {585 // await usingApi(async api => {587 const scheduledId = await makeScheduledId();586 // const scheduledId = await makeScheduledId();588 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);587 // const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);589588590 const bobBalanceBefore = await getFreeBalance(bob);589 // const bobBalanceBefore = await getFreeBalance(bob);591 const waitForBlocks = 4;590 // const waitForBlocks = 4;592 // no need to wait to check, fees must be deducted on scheduling, immediately591 // // no need to wait to check, fees must be deducted on scheduling, immediately593 await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, bob, 0, waitForBlocks, scheduledId);592 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, bob, 0, waitForBlocks, scheduledId);594 const bobBalanceAfter = await getFreeBalance(bob);593 // const bobBalanceAfter = await getFreeBalance(bob);595 // expect(aliceBalanceAfter == aliceBalanceBefore).to.be.true;594 // // expect(aliceBalanceAfter == aliceBalanceBefore).to.be.true;596 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;595 // expect(bobBalanceAfter < bobBalanceBefore).to.be.true;597 // wait for sequentiality matters596 // // wait for sequentiality matters598 await waitNewBlocks(waitForBlocks - 1);597 // await waitNewBlocks(waitForBlocks - 1);599 });598 // });600 });599 });601600602 it('Schedules and dispatches a transaction even if the caller has no funds at the time of the dispatch', async () => {601 it('Schedules and dispatches a transaction even if the caller has no funds at the time of the dispatch', async () => {603 await usingApi(async (api, privateKeyWrapper) => {602 // await usingApi(async (api, privateKeyWrapper) => {604 // Find an empty, unused account603 // // Find an empty, unused account605 const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);604 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);606605607 const collectionId = await createCollectionExpectSuccess();606 // const collectionId = await createCollectionExpectSuccess();608607609 // Add zeroBalance address to allow list608 // // Add zeroBalance address to allow list610 await enablePublicMintingExpectSuccess(alice, collectionId);609 // await enablePublicMintingExpectSuccess(alice, collectionId);611 await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);610 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);612611613 // Grace zeroBalance with money, enough to cover future transactions612 // // Grace zeroBalance with money, enough to cover future transactions614 const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);613 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);615 await submitTransactionAsync(alice, balanceTx);614 // await submitTransactionAsync(alice, balanceTx);616615617 // Mint a fresh NFT616 // // Mint a fresh NFT618 const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT');617 // const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT');619 const scheduledId = await makeScheduledId();618 // const scheduledId = await makeScheduledId();620619621 // Schedule transfer of the NFT a few blocks ahead620 // // Schedule transfer of the NFT a few blocks ahead622 const waitForBlocks = 5;621 // const waitForBlocks = 5;623 await scheduleTransferExpectSuccess(api, collectionId, tokenId, zeroBalance, alice, 1, waitForBlocks, scheduledId);622 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, zeroBalance, alice, 1, waitForBlocks, scheduledId);624623625 // Get rid of the account's funds before the scheduled transaction takes place624 // // Get rid of the account's funds before the scheduled transaction takes place626 const balanceTx2 = api.tx.balances.transfer(alice.address, UNIQUE * 68n / 100n);625 // const balanceTx2 = api.tx.balances.transfer(alice.address, UNIQUE * 68n / 100n);627 const events = await submitTransactionAsync(zeroBalance, balanceTx2);626 // const events = await submitTransactionAsync(zeroBalance, balanceTx2);628 expect(getGenericResult(events).success).to.be.true;627 // expect(getGenericResult(events).success).to.be.true;629 /*const emptyBalanceTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0); // do not null reserved?628 // /*const emptyBalanceTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0); // do not null reserved?630 const sudoTx = api.tx.sudo.sudo(emptyBalanceTx as any);629 // const sudoTx = api.tx.sudo.sudo(emptyBalanceTx as any);631 const events = await submitTransactionAsync(alice, sudoTx);630 // const events = await submitTransactionAsync(alice, sudoTx);632 expect(getGenericResult(events).success).to.be.true;*/631 // expect(getGenericResult(events).success).to.be.true;*/633632634 // Wait for a certain number of blocks, discarding the ones that already happened while accepting the late transactions633 // // Wait for a certain number of blocks, discarding the ones that already happened while accepting the late transactions635 await waitNewBlocks(waitForBlocks - 3);634 // await waitNewBlocks(waitForBlocks - 3);636635637 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));636 // expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));638 });637 // });639 });638 });640639641 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {640 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {642 const collectionId = await createCollectionExpectSuccess();641 // const collectionId = await createCollectionExpectSuccess();643642644 await usingApi(async (api, privateKeyWrapper) => {643 // await usingApi(async (api, privateKeyWrapper) => {645 const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);644 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);646 const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);645 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);647 await submitTransactionAsync(alice, balanceTx);646 // await submitTransactionAsync(alice, balanceTx);648647649 await setCollectionSponsorExpectSuccess(collectionId, zeroBalance.address);648 // await setCollectionSponsorExpectSuccess(collectionId, zeroBalance.address);650 await confirmSponsorshipByKeyExpectSuccess(collectionId, zeroBalance);649 // await confirmSponsorshipByKeyExpectSuccess(collectionId, zeroBalance);651650652 const scheduledId = await makeScheduledId();651 // const scheduledId = await makeScheduledId();653 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);652 // const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);654653655 const waitForBlocks = 5;654 // const waitForBlocks = 5;656 await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, zeroBalance, 1, waitForBlocks, scheduledId);655 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, zeroBalance, 1, waitForBlocks, scheduledId);657656658 const emptyBalanceSponsorTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0);657 // const emptyBalanceSponsorTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0);659 const sudoTx = api.tx.sudo.sudo(emptyBalanceSponsorTx as any);658 // const sudoTx = api.tx.sudo.sudo(emptyBalanceSponsorTx as any);660 const events = await submitTransactionAsync(alice, sudoTx);659 // const events = await submitTransactionAsync(alice, sudoTx);661 expect(getGenericResult(events).success).to.be.true;660 // expect(getGenericResult(events).success).to.be.true;662661663 // Wait for a certain number of blocks, save for the ones that already happened while accepting the late transactions662 // // Wait for a certain number of blocks, save for the ones that already happened while accepting the late transactions664 await waitNewBlocks(waitForBlocks - 3);663 // await waitNewBlocks(waitForBlocks - 3);665664666 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(zeroBalance.address));665 // expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(zeroBalance.address));667 });666 // });668 });667 });669668670 it('Exceeding sponsor rate limit without having enough funds prevents scheduling a periodic transaction', async () => {669 it('Exceeding sponsor rate limit without having enough funds prevents scheduling a periodic transaction', async () => {671 const collectionId = await createCollectionExpectSuccess();670 // const collectionId = await createCollectionExpectSuccess();672 await setCollectionSponsorExpectSuccess(collectionId, bob.address);671 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);673 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');672 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');674673675 await usingApi(async (api, privateKeyWrapper) => {674 // await usingApi(async (api, privateKeyWrapper) => {676 const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);675 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);677676678 await enablePublicMintingExpectSuccess(alice, collectionId);677 // await enablePublicMintingExpectSuccess(alice, collectionId);679 await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);678 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);680679681 const bobBalanceBefore = await getFreeBalance(bob);680 // const bobBalanceBefore = await getFreeBalance(bob);682681683 const createData = {nft: {const_data: [], variable_data: []}};682 // const createData = {nft: {const_data: [], variable_data: []}};684 const creationTx = api.tx.unique.createItem(collectionId, normalizeAccountId(zeroBalance), createData as any);683 // const creationTx = api.tx.unique.createItem(collectionId, normalizeAccountId(zeroBalance), createData as any);685 const scheduledId = await makeScheduledId();684 // const scheduledId = await makeScheduledId();686685686 // /*const badTransaction = async function () {687 // await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);688 // };687 /*const badTransaction = async function () {689 // await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');*/688 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);690689 };691 // await expect(scheduleAfter(api, creationTx, zeroBalance, 3, scheduledId, 1, 3)).to.be.rejectedWith(/Inability to pay some fees/);690 await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');*/692691693 // expect(await getFreeBalance(bob)).to.be.equal(bobBalanceBefore);692 await expect(scheduleAfter(api, creationTx, zeroBalance, 3, scheduledId, 1, 3)).to.be.rejectedWith(/Inability to pay some fees/);694 // });693694 expect(await getFreeBalance(bob)).to.be.equal(bobBalanceBefore);695 });696 });695 });697});696});698697