git.delta.rocks / unique-network / refs/commits / 55817c2dfda1

difftreelog

fix test

Trubnikov Sergey2023-05-19parent: #3c7e64b.patch.diff
in: master

1 file changed

modifiedtests/src/nativeFungible.test.tsdiffbeforeafterboth
before · tests/src/nativeFungible.test.ts
1// Copyright 2019-2023 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from './util';1920describe('Native fungible', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;2324  before(async () => {25    await usingPlaygrounds(async (helper, privateKey) => {26      const donor = await privateKey({url: import.meta.url});27      [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);28    });29  });3031  itSub('destroy_collection()', async ({helper}) => {32    const collection = helper.ft.getCollectionObject(0);33    await expect(collection.burn(alice)).to.be.rejectedWith('common.UnsupportedOperation');34    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.destroyCollection', [0])).to.be.rejectedWith('common.UnsupportedOperation');35  });3637  itSub('add_to_allow_list()', async ({helper}) => {38    const collection = helper.ft.getCollectionObject(0);39    await expect(collection.addToAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');40  });4142  itSub('remove_from_allow_list()', async ({helper}) => {43    const collection = helper.ft.getCollectionObject(0);44    await expect(collection.removeFromAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');45  });4647  itSub('change_collection_owner()', async ({helper}) => {48    const collection = helper.ft.getCollectionObject(0);49    await expect(collection.changeOwner(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');50  });5152  itSub('add_collection_admin()', async ({helper}) => {53    const collection = helper.ft.getCollectionObject(0);54    await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');55  });5657  itSub('remove_collection_admin()', async ({helper}) => {58    const collection = helper.ft.getCollectionObject(0);59    await expect(collection.removeAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');60  });6162  itSub('set_collection_sponsor()', async ({helper}) => {63    const collection = helper.ft.getCollectionObject(0);64    await expect(collection.setSponsor(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');65  });6667  itSub('confirm_sponsorship()', async ({helper}) => {68    const collection = helper.ft.getCollectionObject(0);69    await expect(collection.confirmSponsorship(alice)).to.be.rejectedWith('common.UnsupportedOperation');70  });7172  itSub('remove_collection_sponsor()', async ({helper}) => {73    const collection = helper.ft.getCollectionObject(0);74    await expect(collection.removeSponsor(alice)).to.be.rejectedWith('common.UnsupportedOperation');75  });7677  itSub('create_item()', async ({helper}) => {78    const collection = helper.ft.getCollectionObject(0);79    await expect(collection.mint(alice, 100n, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');80  });8182  itSub('set_collection_properties()', async ({helper}) => {83    const collection = helper.ft.getCollectionObject(0);84    await expect(collection.setProperties(alice, [{key: 'value'}])).to.be.rejectedWith('common.UnsupportedOperation');85  });8687  itSub('delete_collection_properties()', async ({helper}) => {88    const collection = helper.ft.getCollectionObject(0);89    await expect(collection.deleteProperties(alice, ['key'])).to.be.rejectedWith('common.UnsupportedOperation');90  });9192  itSub('set_token_properties()', async ({helper}) => {93    await expect(helper.executeExtrinsic(94      alice,95      'api.tx.unique.setTokenProperties',96      [0, 0, [{key: 'value'}]],97      true,98    )).to.be.rejectedWith('common.UnsupportedOperation');99  });100101  itSub('delete_token_properties()', async ({helper}) => {102    await expect(helper.executeExtrinsic(103      alice,104      'api.tx.unique.deleteTokenProperties',105      [0, 0, ['key']],106      true,107    )).to.be.rejectedWith('common.UnsupportedOperation');108  });109110  itSub('set_transfers_enabled_flag()', async ({helper}) => {111    await expect(helper.executeExtrinsic(112      alice,113      'api.tx.unique.setTransfersEnabledFlag',114      [0, true],115      true,116    )).to.be.rejectedWith('common.UnsupportedOperation');117  });118119  itSub('burn_item()', async ({helper}) => {120    await expect(helper.executeExtrinsic(121      alice,122      'api.tx.unique.burnItem',123      [0, 0, 100n],124      true,125    )).to.be.rejectedWith('common.UnsupportedOperation');126  });127128  itSub('burn_from()', async ({helper}) => {129    const collection = helper.ft.getCollectionObject(0);130    await expect(collection.burnTokens(alice, 100n)).to.be.rejectedWith('common.UnsupportedOperation');131  });132133  itSub('transfer()', async ({helper}) => {134    const collection = helper.ft.getCollectionObject(0);135    const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);136    const balanceBobBefore = await helper.balance.getSubstrate(bob.address);137    await collection.transfer(alice, {Substrate: bob.address}, 100n);138    const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);139    const balanceBobAfter = await helper.balance.getSubstrate(bob.address);140    expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;141    expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;142  });143144  itSub('transfer_from()', async ({helper}) => {145    const collection = helper.ft.getCollectionObject(0);146    const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);147    const balanceBobBefore = await helper.balance.getSubstrate(bob.address);148149    await collection.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address}, 100n);150151    const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);152    const balanceBobAfter = await helper.balance.getSubstrate(bob.address);153    expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;154    expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;155156    await expect(collection.transferFrom(alice, {Substrate: bob.address}, {Substrate: alice.address}, 100n)).to.be.rejectedWith('common.ApprovedValueTooLow');157  });158159  itSub('approve()', async ({helper}) => {160    const collection = helper.ft.getCollectionObject(0);161    await expect(collection.approveTokens(alice, {Substrate: bob.address}, 100n)).to.be.rejectedWith('common.UnsupportedOperation');162  });163164  itSub('approve_from()', async ({helper}) => {165    await expect(helper.executeExtrinsic(166      alice,167      'api.tx.unique.approveFrom',168      [{Substrate: alice.address}, {Substrate: bob.address}, 0, 0, 100n],169      true,170    )).to.be.rejectedWith('common.UnsupportedOperation');171  });172173  itSub('set_collection_limits()', async ({helper}) => {174    const collection = helper.ft.getCollectionObject(0);175    await expect(collection.setLimits(alice, {accountTokenOwnershipLimit: 1})).to.be.rejectedWith('common.UnsupportedOperation');176  });177178  itSub('set_collection_permissions()', async ({helper}) => {179    const collection = helper.ft.getCollectionObject(0);180    await expect(collection.setPermissions(alice, {access: 'AllowList'})).to.be.rejectedWith('common.UnsupportedOperation');181  });182183  itSub('repartition()', async ({helper}) => {184    await expect(helper.executeExtrinsic(185      alice,186      'api.tx.unique.repartition',187      [0, 0, 100n],188      true,189    )).to.be.rejectedWith('unique.RepartitionCalledOnNonRefungibleCollection');190  });191192  itSub('force_repair_collection()', async ({helper}) => {193    await expect(helper.executeExtrinsic(194      alice,195      'api.tx.unique.forceRepairCollection',196      [0],197      true,198    )).to.be.rejectedWith('common.UnsupportedOperation');199  });200201  itSub('force_repair_item()', async ({helper}) => {202    await expect(helper.executeExtrinsic(203      alice,204      'api.tx.unique.forceRepairItem',205      [0, 0],206      true,207    )).to.be.rejectedWith('BadOrigin');208  });209210  itSub('Nest into NFT token()', async ({helper}) => {211    const nftCollection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});212    const targetToken = await nftCollection.mintToken(alice);213214    const collection = helper.ft.getCollectionObject(0);215    await collection.transfer(alice, targetToken.nestingAccount(), 100n);216217    await collection.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 100n);218  });219});
after · tests/src/nativeFungible.test.ts
1// Copyright 2019-2023 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from './util';1920describe('Native fungible', () => {21  let root: IKeyringPair;22  let alice: IKeyringPair;23  let bob: IKeyringPair;2425  before(async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      root = await privateKey('//Alice');28      const donor = await privateKey({url: import.meta.url});29      [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);30    });31  });3233  itSub('destroy_collection()', async ({helper}) => {34    const collection = helper.ft.getCollectionObject(0);35    await expect(collection.burn(alice)).to.be.rejectedWith('common.UnsupportedOperation');36    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.destroyCollection', [0])).to.be.rejectedWith('common.UnsupportedOperation');37  });3839  itSub('add_to_allow_list()', async ({helper}) => {40    const collection = helper.ft.getCollectionObject(0);41    await expect(collection.addToAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');42  });4344  itSub('remove_from_allow_list()', async ({helper}) => {45    const collection = helper.ft.getCollectionObject(0);46    await expect(collection.removeFromAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');47  });4849  itSub('change_collection_owner()', async ({helper}) => {50    const collection = helper.ft.getCollectionObject(0);51    await expect(collection.changeOwner(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');52  });5354  itSub('add_collection_admin()', async ({helper}) => {55    const collection = helper.ft.getCollectionObject(0);56    await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');57  });5859  itSub('remove_collection_admin()', async ({helper}) => {60    const collection = helper.ft.getCollectionObject(0);61    await expect(collection.removeAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');62  });6364  itSub('set_collection_sponsor()', async ({helper}) => {65    const collection = helper.ft.getCollectionObject(0);66    await expect(collection.setSponsor(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');67  });6869  itSub('confirm_sponsorship()', async ({helper}) => {70    const collection = helper.ft.getCollectionObject(0);71    await expect(collection.confirmSponsorship(alice)).to.be.rejectedWith('common.UnsupportedOperation');72  });7374  itSub('remove_collection_sponsor()', async ({helper}) => {75    const collection = helper.ft.getCollectionObject(0);76    await expect(collection.removeSponsor(alice)).to.be.rejectedWith('common.UnsupportedOperation');77  });7879  itSub('create_item()', async ({helper}) => {80    const collection = helper.ft.getCollectionObject(0);81    await expect(collection.mint(alice, 100n, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');82  });8384  itSub('set_collection_properties()', async ({helper}) => {85    const collection = helper.ft.getCollectionObject(0);86    await expect(collection.setProperties(alice, [{key: 'value'}])).to.be.rejectedWith('common.UnsupportedOperation');87  });8889  itSub('delete_collection_properties()', async ({helper}) => {90    const collection = helper.ft.getCollectionObject(0);91    await expect(collection.deleteProperties(alice, ['key'])).to.be.rejectedWith('common.UnsupportedOperation');92  });9394  itSub('set_token_properties()', async ({helper}) => {95    await expect(helper.executeExtrinsic(96      alice,97      'api.tx.unique.setTokenProperties',98      [0, 0, [{key: 'value'}]],99      true,100    )).to.be.rejectedWith('common.UnsupportedOperation');101  });102103  itSub('delete_token_properties()', async ({helper}) => {104    await expect(helper.executeExtrinsic(105      alice,106      'api.tx.unique.deleteTokenProperties',107      [0, 0, ['key']],108      true,109    )).to.be.rejectedWith('common.UnsupportedOperation');110  });111112  itSub('set_transfers_enabled_flag()', async ({helper}) => {113    await expect(helper.executeExtrinsic(114      alice,115      'api.tx.unique.setTransfersEnabledFlag',116      [0, true],117      true,118    )).to.be.rejectedWith('common.UnsupportedOperation');119  });120121  itSub('burn_item()', async ({helper}) => {122    await expect(helper.executeExtrinsic(123      alice,124      'api.tx.unique.burnItem',125      [0, 0, 100n],126      true,127    )).to.be.rejectedWith('common.UnsupportedOperation');128  });129130  itSub('burn_from()', async ({helper}) => {131    const collection = helper.ft.getCollectionObject(0);132    await expect(collection.burnTokens(alice, 100n)).to.be.rejectedWith('common.UnsupportedOperation');133  });134135  itSub('transfer()', async ({helper}) => {136    const collection = helper.ft.getCollectionObject(0);137    const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);138    const balanceBobBefore = await helper.balance.getSubstrate(bob.address);139    await collection.transfer(alice, {Substrate: bob.address}, 100n);140    const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);141    const balanceBobAfter = await helper.balance.getSubstrate(bob.address);142    expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;143    expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;144  });145146  itSub('transfer_from()', async ({helper}) => {147    const collection = helper.ft.getCollectionObject(0);148    const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);149    const balanceBobBefore = await helper.balance.getSubstrate(bob.address);150151    await collection.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address}, 100n);152153    const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);154    const balanceBobAfter = await helper.balance.getSubstrate(bob.address);155    expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;156    expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;157158    await expect(collection.transferFrom(alice, {Substrate: bob.address}, {Substrate: alice.address}, 100n)).to.be.rejectedWith('common.ApprovedValueTooLow');159  });160161  itSub('approve()', async ({helper}) => {162    const collection = helper.ft.getCollectionObject(0);163    await expect(collection.approveTokens(alice, {Substrate: bob.address}, 100n)).to.be.rejectedWith('common.UnsupportedOperation');164  });165166  itSub('approve_from()', async ({helper}) => {167    await expect(helper.executeExtrinsic(168      alice,169      'api.tx.unique.approveFrom',170      [{Substrate: alice.address}, {Substrate: bob.address}, 0, 0, 100n],171      true,172    )).to.be.rejectedWith('common.UnsupportedOperation');173  });174175  itSub('set_collection_limits()', async ({helper}) => {176    const collection = helper.ft.getCollectionObject(0);177    await expect(collection.setLimits(alice, {accountTokenOwnershipLimit: 1})).to.be.rejectedWith('common.UnsupportedOperation');178  });179180  itSub('set_collection_permissions()', async ({helper}) => {181    const collection = helper.ft.getCollectionObject(0);182    await expect(collection.setPermissions(alice, {access: 'AllowList'})).to.be.rejectedWith('common.UnsupportedOperation');183  });184185  itSub('repartition()', async ({helper}) => {186    await expect(helper.executeExtrinsic(187      alice,188      'api.tx.unique.repartition',189      [0, 0, 100n],190      true,191    )).to.be.rejectedWith('unique.RepartitionCalledOnNonRefungibleCollection');192  });193194  itSub('force_repair_collection()', async ({helper}) => {195    await expect(helper.executeExtrinsic(196      alice,197      'api.tx.unique.forceRepairCollection',198      [0],199      true,200    )).to.be.rejectedWith('common.UnsupportedOperation');201  });202203  itSub('force_repair_item()', async ({helper}) => {204    await expect(helper.getSudo().executeExtrinsic(205      root,206      'api.tx.unique.forceRepairItem',207      [0, 0],208      true,209    )).to.be.rejectedWith('common.UnsupportedOperation');210  });211212  itSub('Nest into NFT token()', async ({helper}) => {213    const nftCollection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});214    const targetToken = await nftCollection.mintToken(alice);215216    const collection = helper.ft.getCollectionObject(0);217    await collection.transfer(alice, targetToken.nestingAccount(), 100n);218219    await collection.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 100n);220  });221});