git.delta.rocks / unique-network / refs/commits / d856e8716cfd

difftreelog

createItem migrated

rkv2022-09-12parent: #792a004.patch.diff
in: master

1 file changed

modifiedtests/src/createItem.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {default as usingApi, executeTransaction} from './substrate/substrate-api';
18import chai from 'chai';17import chai from 'chai';
18import chaiAsPromised from 'chai-as-promised';
19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';
20import {20import {
21 createCollectionExpectSuccess,
22 createItemExpectSuccess,
23 addCollectionAdminExpectSuccess,
24 createCollectionWithPropsExpectSuccess,
25 createItemWithPropsExpectSuccess,
26 createItemWithPropsExpectFailure,
27 createCollection,21 createCollection,
28 transferExpectSuccess,
29 itApi,22 itApi,
30 normalizeAccountId,23 normalizeAccountId,
31 getCreateItemResult,24 getCreateItemResult,
32 requirePallets,
33 Pallets,
34} from './util/helpers';25} from './util/helpers';
26import {usingPlaygrounds} from './util/playgrounds';
27import {IProperty} from './util/playgrounds/types';
28import {executeTransaction} from './substrate/substrate-api';
3529
30chai.use(chaiAsPromised);
36const expect = chai.expect;31const expect = chai.expect;
32
33let donor: IKeyringPair;
34
35before(async () => {
36 await usingPlaygrounds(async (_, privateKey) => {
37 donor = privateKey('//Alice');
38 });
39});
40
37let alice: IKeyringPair;41let alice: IKeyringPair;
38let bob: IKeyringPair;42let bob: IKeyringPair;
3943
40describe('integration test: ext. ():', () => {44describe('integration test: ext. ():', () => {
41 before(async () => {45 before(async () => {
42 await usingApi(async (api, privateKeyWrapper) => {46 await usingPlaygrounds(async (helper) => {
43 alice = privateKeyWrapper('//Alice');47 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
44 bob = privateKeyWrapper('//Bob');
45 });48 });
46 });49 });
4750
48 it('Create new item in NFT collection', async () => {51 it('Create new item in NFT collection', async () => {
49 const createMode = 'NFT';52 await usingPlaygrounds(async (helper) => {
50 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});53 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
51 await createItemExpectSuccess(alice, newCollectionID, createMode);54 await collection.mintToken(alice, {Substrate: alice.address});
55 });
52 });56 });
53 it('Create new item in Fungible collection', async () => {57 it('Create new item in Fungible collection', async () => {
54 const createMode = 'Fungible';58 await usingPlaygrounds(async (helper) => {
55 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});59 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
56 await createItemExpectSuccess(alice, newCollectionID, createMode);60 await collection.mint(alice, {Substrate: alice.address}, 10n);
61 });
57 });62 });
58 itApi('Check events on create new item in Fungible collection', async ({api}) => {63 itApi.skip('Check events on create new item in Fungible collection', async ({api}) => {
59 const createMode = 'Fungible';64 const createMode = 'Fungible';
60 65
61 const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;66 const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;
62 67
63 const to = normalizeAccountId(alice);68 const to = normalizeAccountId(alice);
64 {69 {
65 const createData = {fungible: {value: 100}};70 const createData = {fungible: {value: 100}};
8287
83 });88 });
84 it('Create new item in ReFungible collection', async function() {89 it('Create new item in ReFungible collection', async function() {
85 await requirePallets(this, [Pallets.ReFungible]);90 await usingPlaygrounds(async (helper) => {
86
87 const createMode = 'ReFungible';91 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
88 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
89 await createItemExpectSuccess(alice, newCollectionID, createMode);92 await collection.mintToken(alice, {Substrate: alice.address}, 100n);
93 });
90 });94 });
91 it('Create new item in NFT collection with collection admin permissions', async () => {95 it('Create new item in NFT collection with collection admin permissions', async () => {
92 const createMode = 'NFT';96 await usingPlaygrounds(async (helper) => {
93 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});97 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
94 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);98 await collection.addAdmin(alice, {Substrate: bob.address});
95 await createItemExpectSuccess(bob, newCollectionID, createMode);99 await collection.mintToken(bob, {Substrate: alice.address});
100 });
96 });101 });
97 it('Create new item in Fungible collection with collection admin permissions', async () => {102 it('Create new item in Fungible collection with collection admin permissions', async () => {
98 const createMode = 'Fungible';103 await usingPlaygrounds(async (helper) => {
99 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});104 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
100 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);105 await collection.addAdmin(alice, {Substrate: bob.address});
101 await createItemExpectSuccess(bob, newCollectionID, createMode);106 await collection.mint(bob, {Substrate: alice.address}, 10n);
107 });
102 });108 });
103 it('Create new item in ReFungible collection with collection admin permissions', async function() {109 it('Create new item in ReFungible collection with collection admin permissions', async function() {
104 await requirePallets(this, [Pallets.ReFungible]);110 await usingPlaygrounds(async (helper) => {
105
106 const createMode = 'ReFungible';111 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
107 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
108 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);112 await collection.addAdmin(alice, {Substrate: bob.address});
109 await createItemExpectSuccess(bob, newCollectionID, createMode);113 await collection.mintToken(bob, {Substrate: alice.address}, 100n);
114 });
110 });115 });
111116
112 it('Set property Admin', async () => {117 it('Set property Admin', async () => {
113 const createMode = 'NFT';118 await usingPlaygrounds(async (helper) => {
114 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 119 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
115 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});120 properties: [{key: 'k', value: 'v'}],
121 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}}],
122 });
116 123 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
117 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);124 });
118 });125 });
119126
120 it('Set property AdminConst', async () => {127 it('Set property AdminConst', async () => {
121 const createMode = 'NFT';128 await usingPlaygrounds(async (helper) => {
122 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 129 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
123 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});130 properties: [{key: 'k', value: 'v'}],
131 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}}],
132 });
124 133 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
125 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);134 });
126 });135 });
127136
128 it('Set property itemOwnerOrAdmin', async () => {137 it('Set property itemOwnerOrAdmin', async () => {
129 const createMode = 'NFT';138 await usingPlaygrounds(async (helper) => {
130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},139 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
140 properties: [{key: 'k', value: 'v'}],
131 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});141 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}}],
142 });
132 143 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
133 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);144 });
134 });145 });
135146
136 it('Check total pieces of Fungible token', async () => {147 it('Check total pieces of Fungible token', async () => {
137 await usingApi(async api => {148 await usingPlaygrounds(async (helper) => {
138 const createMode = 'Fungible';149 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
139 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
140 const amountPieces = 10n;150 const amount = 10n;
141 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);151 await collection.mint(alice, {Substrate: bob.address}, amount);
142 {152 {
143 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);153 const totalPieces = await collection.getTotalPieces();
144 expect(totalPieces.isSome).to.be.true;154 expect(totalPieces).to.be.equal(amount);
145 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);
146 }155 }
147
148 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);156 await collection.transfer(bob, {Substrate: alice.address}, 1n);
149 {157 {
150 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);158 const totalPieces = await collection.getTotalPieces();
151 expect(totalPieces.isSome).to.be.true;159 expect(totalPieces).to.be.equal(amount);
152 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);
153 }160 }
154
155 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;
156 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
157 });161 });
158 });162 });
159163
160 it('Check total pieces of NFT token', async () => {164 it('Check total pieces of NFT token', async () => {
161 await usingApi(async api => {165 await usingPlaygrounds(async (helper) => {
162 const createMode = 'NFT';166 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
163 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
164 const amountPieces = 1n;167 const amount = 1n;
165 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);168 const token = await collection.mintToken(alice, {Substrate: bob.address});
166 {169 {
167 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);170 const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);
168 expect(totalPieces.isSome).to.be.true;
169 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);171 expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);
170 }172 }
171
172 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);173 await token.transfer(bob, {Substrate: alice.address});
173 {174 {
174 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);175 const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);
175 expect(totalPieces.isSome).to.be.true;
176 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);176 expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);
177 }177 }
178
179 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;
180 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
181 });178 });
182 });179 });
183180
184 it('Check total pieces of ReFungible token', async function() {181 it('Check total pieces of ReFungible token', async function() {
185 await requirePallets(this, [Pallets.ReFungible]);182 await usingPlaygrounds(async (helper) => {
186
187 await usingApi(async api => {
188 const createMode = 'ReFungible';183 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
189 const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});
190 const collectionId = createCollectionResult.collectionId;184 const amount = 100n;
191 const amountPieces = 100n;
192 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);185 const token = await collection.mintToken(alice, {Substrate: bob.address}, amount);
193 {186 {
194 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);187 const totalPieces = await token.getTotalPieces();
195 expect(totalPieces.isSome).to.be.true;188 expect(totalPieces).to.be.equal(amount);
196 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);
197 }189 }
198
199 await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);190 await token.transfer(bob, {Substrate: alice.address}, 60n);
200 {191 {
201 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);192 const totalPieces = await token.getTotalPieces();
202 expect(totalPieces.isSome).to.be.true;193 expect(totalPieces).to.be.equal(amount);
203 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);
204 }194 }
205
206 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;
207 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);
208 });195 });
209 });196 });
210});197});
211198
212describe('Negative integration test: ext. createItem():', () => {199describe('Negative integration test: ext. createItem():', () => {
213 before(async () => {200 before(async () => {
214 await usingApi(async (api, privateKeyWrapper) => {201 await usingPlaygrounds(async (helper) => {
215 alice = privateKeyWrapper('//Alice');202 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
216 bob = privateKeyWrapper('//Bob');
217 });203 });
218 });204 });
219205
220 it('Regular user cannot create new item in NFT collection', async () => {206 it('Regular user cannot create new item in NFT collection', async () => {
221 const createMode = 'NFT';207 await usingPlaygrounds(async (helper) => {
222 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});208 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
223 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;209 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});
210 await expect(mintTx()).to.be.rejected;
211 });
224 });212 });
225 it('Regular user cannot create new item in Fungible collection', async () => {213 it('Regular user cannot create new item in Fungible collection', async () => {
226 const createMode = 'Fungible';214 await usingPlaygrounds(async (helper) => {
227 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});215 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
228 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;216 const mintTx = async () => collection.mint(bob, {Substrate: bob.address}, 10n);
217 await expect(mintTx()).to.be.rejected;
218 });
229 });219 });
230 it('Regular user cannot create new item in ReFungible collection', async function() {220 it('Regular user cannot create new item in ReFungible collection', async () => {
231 await requirePallets(this, [Pallets.ReFungible]);221 await usingPlaygrounds(async (helper) => {
232
233 const createMode = 'ReFungible';222 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
234 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});223 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});
235 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;224 await expect(mintTx()).to.be.rejected;
225 });
236 });226 });
237227
238 it('No editing rights', async () => {228 it('No editing rights', async () => {
239 await usingApi(async () => {229 await usingPlaygrounds(async (helper) => {
240 const createMode = 'NFT';230 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
241 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},
242 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});231 tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],
243 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);232 });
244
245 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);233 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
234 await expect(mintTx()).to.be.rejected;
246 });235 });
247 });236 });
248237
249 it('User doesnt have editing rights', async () => {238 it('User doesnt have editing rights', async () => {
250 await usingApi(async () => {239 await usingPlaygrounds(async (helper) => {
251 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});240 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
241 tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
242 });
252 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);243 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
244 await expect(mintTx()).to.be.rejected;
253 });245 });
254 });246 });
255247
256 it('Adding property without access rights', async () => {248 it('Adding property without access rights', async () => {
257 await usingApi(async () => {249 await usingPlaygrounds(async (helper) => {
258 const newCollectionID = await createCollectionWithPropsExpectSuccess();250 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
259 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
260
261 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);251 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
252 await expect(mintTx()).to.be.rejected;
262 });253 });
263 });254 });
264255
265 it('Adding more than 64 prps', async () => {256 it('Adding more than 64 prps', async () => {
266 await usingApi(async () => {257 const props: IProperty[] = [];
267 const prps = [];
268258
269 for (let i = 0; i < 65; i++) {259 for (let i = 0; i < 65; i++) {
270 prps.push({key: `key${i}`, value: `value${i}`});260 props.push({key: `key${i}`, value: `value${i}`});
271 }261 }
272262
273 const newCollectionID = await createCollectionWithPropsExpectSuccess();263 await usingPlaygrounds(async (helper) => {
264 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
274 265 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);
275 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);266 await expect(mintTx()).to.be.rejected;
276 });267 });
277 });268 });
278269
279 it('Trying to add bigger property than allowed', async () => {270 it('Trying to add bigger property than allowed', async () => {
280 await usingApi(async () => {271 await usingPlaygrounds(async (helper) => {
281 const newCollectionID = await createCollectionWithPropsExpectSuccess();272 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
282 273 tokenPropertyPermissions: [
283 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);274 {key: 'k1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},
275 {key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},
276 ],
277 });
278 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [
279 {key: 'k1', value: 'vvvvvv'.repeat(5000)},
280 {key: 'k2', value: 'vvv'.repeat(5000)},
281 ]);
282 await expect(mintTx()).to.be.rejected;
284 });283 });
285 });284 });
286285
287 it('Check total pieces for invalid Fungible token', async () => {286 it('Check total pieces for invalid Fungible token', async () => {
288 await usingApi(async api => {287 await usingPlaygrounds(async (helper) => {
289 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});288 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
290 const collectionId = createCollectionResult.collectionId;289 const invalidTokenId = 1_000_000;
291 const invalidTokenId = 1000_000;
292 290 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
293 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;
294 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);291 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
295 });292 });
296 });293 });
297294
298 it('Check total pieces for invalid NFT token', async () => {295 it('Check total pieces for invalid NFT token', async () => {
299 await usingApi(async api => {296 await usingPlaygrounds(async (helper) => {
300 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});297 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
301 const collectionId = createCollectionResult.collectionId;298 const invalidTokenId = 1_000_000;
302 const invalidTokenId = 1000_000;
303 299 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
304 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;
305 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);300 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
306 });301 });
307 });302 });
308303
309 it('Check total pieces for invalid Refungible token', async function() {304 it('Check total pieces for invalid Refungible token', async function() {
310 await requirePallets(this, [Pallets.ReFungible]);305 await usingPlaygrounds(async (helper) => {
311
312 await usingApi(async api => {
313 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});306 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
314 const collectionId = createCollectionResult.collectionId;307 const invalidTokenId = 1_000_000;
315 const invalidTokenId = 1000_000;
316 308 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
317 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;
318 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);309 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
319 });310 });
320 });311 });
321});312});