difftreelog
test add fungible and refungible to createMultipleItemsEx
in: master
1 file changed
tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth161617import {expect} from 'chai';17import {expect} from 'chai';18import usingApi, {executeTransaction} from './substrate/substrate-api';18import usingApi, {executeTransaction} from './substrate/substrate-api';19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess} from './util/helpers';19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, getBalance, getLastTokenId} from './util/helpers';202021describe('createMultipleItemsEx', () => {21describe('Integration Test: createMultipleItemsEx', () => {22 it('can initialize multiple NFT with different owners', async () => {22 it('can initialize multiple NFT with different owners', async () => {23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});24 await usingApi(async (api, privateKeyWrapper) => {24 await usingApi(async (api, privateKeyWrapper) => {128 });128 });129 });129 });130130131 it('can initialize fungible with multiple owners', async () => {132 const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});133 await usingApi(async (api, privateKeyWrapper) => {134 const alice = privateKeyWrapper('//Alice');135 const bob = privateKeyWrapper('//Bob');136137 const users = new Map();138 users.set(JSON.stringify({Substrate: alice.address}), 50);139 users.set(JSON.stringify({Substrate: bob.address}), 100);140141 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {142 Fungible: users,143 }));144145 expect(await getBalance(api, collection, alice.address, 0)).to.equal(50n);146 expect(await getBalance(api, collection, bob.address, 0)).to.equal(100n);147 });148 });149150 it('can initialize an RFT with multiple owners', async () => {151 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});152 await usingApi(async (api, privateKeyWrapper) => {153 const alice = privateKeyWrapper('//Alice');154 const bob = privateKeyWrapper('//Bob');155156 const users = new Map();157 users.set(JSON.stringify({Substrate: alice.address}), 1);158 users.set(JSON.stringify({Substrate: bob.address}), 2);159160 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {161 RefungibleMultipleOwners: {162 users: users,163 },164 }));165 166 const itemsListIndexAfter = await getLastTokenId(api, collection);167 expect(itemsListIndexAfter).to.be.equal(1);168169 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);170 expect(await getBalance(api, collection, bob.address, 1)).to.be.equal(2n);171 });172 });173174 it('can initialize multiple RFTs with the same owner', async () => {175 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});176 await usingApi(async (api, privateKeyWrapper) => {177 const alice = privateKeyWrapper('//Alice');178179 const item1User = new Map();180 item1User.set(JSON.stringify({Substrate: alice.address}), 1);181182 const item2User = new Map();183 item2User.set(JSON.stringify({Substrate: alice.address}), 3);184185 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {186 RefungibleMultipleItems: [187 {users: item1User},188 {users: item2User},189 ],190 }));191 192 const itemsListIndexAfter = await getLastTokenId(api, collection);193 expect(itemsListIndexAfter).to.be.equal(2);194195 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);196 expect(await getBalance(api, collection, alice.address, 2)).to.be.equal(3n);197 });198 });199});200201describe('Negative test: createMultipleItemsEx', () => {131 it('No editing rights', async () => {202 it('No editing rights', async () => {132 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],203 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],133 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});204 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});321 });392 });322 });393 });323});394});324'';325395