difftreelog
fix createMultipleItemsEx remove skip tests
in: master
1 file changed
tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth161617import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, Pallets, itSub} from './util/playgrounds';18import {usingPlaygrounds, expect, Pallets, itSub} from './util/playgrounds';19import usingApi, {executeTransaction} from './substrate/substrate-api';20import {createCollectionExpectSuccess, getBalance, getLastTokenId, getTokenProperties, requirePallets} from './util/helpers';21import {IProperty} from './util/playgrounds/types';19import {IProperty} from './util/playgrounds/types';222023describe('Integration Test: createMultipleItemsEx', () => {21describe('Integration Test: createMultipleItemsEx', () => {173 }171 }174 });172 });175173176 it.skip('can initialize fungible with multiple owners', async () => {174 itSub('can initialize fungible with multiple owners', async ({helper}) => {177 const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});175 const collection = await helper.ft.mintCollection(alice, {176 name: 'name',177 description: 'descr',178 tokenPrefix: 'COL',179 }, 0);180181 const api = helper.api;178 await usingApi(async (api, privateKeyWrapper) => {182 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {179 const alice = privateKeyWrapper('//Alice');180 const bob = privateKeyWrapper('//Bob');181182 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {183 Fungible: new Map([183 Fungible: new Map([184 [JSON.stringify({Substrate: alice.address}), 50],184 [JSON.stringify({Substrate: alice.address}), 50],185 [JSON.stringify({Substrate: bob.address}), 100],185 [JSON.stringify({Substrate: bob.address}), 100],186 ]),186 ]),187 }));187 }));188188189 expect(await getBalance(api, collection, alice.address, 0)).to.equal(50n);189 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);190 expect(await getBalance(api, collection, bob.address, 0)).to.equal(100n);190 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);191 });192 });191 });193192194 it.skip('can initialize an RFT with multiple owners', async function() {193 itSub.ifWithPallets('can initialize an RFT with multiple owners', [Pallets.ReFungible], async ({helper}) => {195 await requirePallets(this, [Pallets.ReFungible]);196197 await usingApi(async (api, privateKeyWrapper) => {198 const alice = privateKeyWrapper('//Alice');199 const bob = privateKeyWrapper('//Bob');200 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});201 await executeTransaction(194 const collection = await helper.rft.mintCollection(alice, {202 api,203 alice,204 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'data', permission: {tokenOwner: true}}]),195 name: 'name',205 );196 description: 'descr',206197 tokenPrefix: 'COL',198 tokenPropertyPermissions: [199 {key: 'k', permission: {tokenOwner: true, mutable: false, collectionAdmin: false}},200 ],201 });202203 const api = helper.api;207 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {204 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {208 RefungibleMultipleOwners: {205 RefungibleMultipleOwners: {209 users: new Map([206 users: new Map([210 [JSON.stringify({Substrate: alice.address}), 1],207 [JSON.stringify({Substrate: alice.address}), 1],211 [JSON.stringify({Substrate: bob.address}), 2],208 [JSON.stringify({Substrate: bob.address}), 2],212 ]),209 ]),213 properties: [210 properties: [214 {key: 'data', value: 'testValue'},211 {key: 'k', value: 'v'},215 ],212 ],216 },213 },217 }));214 }));218219 const itemsListIndexAfter = await getLastTokenId(api, collection);215 const tokenId = await collection.getLastTokenId();220 expect(itemsListIndexAfter).to.be.equal(1);216 expect(tokenId).to.be.equal(1);221222 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);217 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);223 expect(await getBalance(api, collection, bob.address, 1)).to.be.equal(2n);218 expect(await collection.getTokenBalance(1, {Substrate: bob.address})).to.be.equal(2n);224 expect((await getTokenProperties(api, collection, 1, ['data']))[0].value).to.be.equal('testValue');225 });219 });226 });227220228 it.skip('can initialize multiple RFTs with the same owner', async function() {221 itSub.ifWithPallets('can initialize multiple RFTs with the same owner', [Pallets.ReFungible], async ({helper}) => {229 await requirePallets(this, [Pallets.ReFungible]);230231 await usingApi(async (api, privateKeyWrapper) => {232 const alice = privateKeyWrapper('//Alice');233 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});234 await executeTransaction(222 const collection = await helper.rft.mintCollection(alice, {235 api,236 alice,237 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'data', permission: {tokenOwner: true}}]),223 name: 'name',238 );224 description: 'descr',225 tokenPrefix: 'COL',226 tokenPropertyPermissions: [227 {key: 'k', permission: {tokenOwner: true, mutable: false, collectionAdmin: false}},228 ],229 });230231 const api = helper.api;239232240 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {233 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {241 RefungibleMultipleItems: [234 RefungibleMultipleItems: [242 {235 {243 user: {Substrate: alice.address}, pieces: 1,236 user: {Substrate: alice.address}, pieces: 1,244 properties: [237 properties: [245 {key: 'data', value: 'testValue1'},238 {key: 'k', value: 'v1'},246 ],239 ],247 },240 },248 {241 {249 user: {Substrate: alice.address}, pieces: 3,242 user: {Substrate: alice.address}, pieces: 3,250 properties: [243 properties: [251 {key: 'data', value: 'testValue2'},244 {key: 'k', value: 'v2'},252 ],245 ],253 },246 },254 ],247 ],255 }));248 }));256249257 const itemsListIndexAfter = await getLastTokenId(api, collection);258 expect(itemsListIndexAfter).to.be.equal(2);250 expect(await collection.getLastTokenId()).to.be.equal(2);259260 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);251 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);261 expect(await getBalance(api, collection, alice.address, 2)).to.be.equal(3n);252 expect(await collection.getTokenBalance(2, {Substrate: alice.address})).to.be.equal(3n);253254 const tokenData1 = await helper.rft.getToken(collection.collectionId, 1);255 expect(tokenData1).to.not.be.null;262 expect((await getTokenProperties(api, collection, 1, ['data']))[0].value).to.be.equal('testValue1');256 expect(tokenData1?.properties[0]).to.be.deep.equal({key: 'k', value: 'v1'});257258 const tokenData2 = await helper.rft.getToken(collection.collectionId, 2);259 expect(tokenData2).to.not.be.null;263 expect((await getTokenProperties(api, collection, 2, ['data']))[0].value).to.be.equal('testValue2');260 expect(tokenData2?.properties[0]).to.be.deep.equal({key: 'k', value: 'v2'});264 });261 });265 });266});262});267263268describe('Negative test: createMultipleItemsEx', () => {264describe('Negative test: createMultipleItemsEx', () => {