git.delta.rocks / unique-network / refs/commits / 027824533e7e

difftreelog

test use new burn value logic

Yaroslav Bolyukin2021-10-11parent: #91ce31e.patch.diff
in: master

3 files changed

modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
92 });92 });
93 });93 });
9494
95 it.only('Burn owned portion of item in ReFungible collection', async () => {95 it('Burn owned portion of item in ReFungible collection', async () => {
96 const createMode = 'ReFungible';96 const createMode = 'ReFungible';
97 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});97 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
98 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);98 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
107 const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();107 const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
108108
109 // Bob burns his portion109 // Bob burns his portion
110 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);110 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
111 const events2 = await submitTransactionAsync(bob, tx);111 const events2 = await submitTransactionAsync(bob, tx);
112 const result2 = getGenericResult(events2);112 const result2 = getGenericResult(events2);
113113
114 // Get balances 114 // Get balances
115 const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();115 const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
116 // console.log(balance);116 // console.log(balance);
117 117
152 await addCollectionAdminExpectSuccess(alice, collectionId, bob);152 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
153153
154 await usingApi(async (api) => {154 await usingApi(async (api) => {
155 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);155 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
156 const events = await submitTransactionAsync(bob, tx);156 const events = await submitTransactionAsync(bob, tx);
157 const result = getGenericResult(events);157 const result = getGenericResult(events);
158 // Get the item158 // Get the item
166 });166 });
167167
168168
169 it.only('Burn item in Fungible collection', async () => {169 it('Burn item in Fungible collection', async () => {
170 const createMode = 'Fungible';170 const createMode = 'Fungible';
171 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});171 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
172 await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens172 await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
179 const events = await submitTransactionAsync(bob, tx);179 const events = await submitTransactionAsync(bob, tx);
180 const result = getGenericResult(events);180 const result = getGenericResult(events);
181 181
182 // Get alice balance 182 // Get alice balance
183 const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();183 const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
184 184
185 // What to expect185 // What to expect
189 });189 });
190 });190 });
191 191
192 it.only('Burn item in ReFungible collection', async () => {192 it('Burn item in ReFungible collection', async () => {
193 const createMode = 'ReFungible';193 const createMode = 'ReFungible';
194 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});194 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
195 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);195 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
196 await addCollectionAdminExpectSuccess(alice, collectionId, bob);196 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
197197
198 await usingApi(async (api) => {198 await usingApi(async (api) => {
199 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);199 const tx = api.tx.nft.burnItem(collectionId, tokenId, 100);
200 const events = await submitTransactionAsync(bob, tx);200 const events = await submitTransactionAsync(bob, tx);
201 const result = getGenericResult(events);201 const result = getGenericResult(events);
202 // Get alice balance 202 // Get alice balance
203 const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();203 const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
204 204
205 // What to expect205 // What to expect
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
184 1,184 1,
185 );185 );
186 });186 });
187 it.only('Transfer with deleted item_id', async () => {187 it('Transfer with deleted item_id', async () => {
188 // nft188 // nft
189 const nftCollectionId = await createCollectionExpectSuccess();189 const nftCollectionId = await createCollectionExpectSuccess();
190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
199 const reFungibleCollectionId = await199 const reFungibleCollectionId = await
200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 100);
203 await transferExpectFailure(203 await transferExpectFailure(
204 reFungibleCollectionId,204 reFungibleCollectionId,
205 newReFungibleTokenId,205 newReFungibleTokenId,
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
251 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1); 251 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
252 });252 });
253 });253 });
254 it.only( 'transferFrom burnt token before approve Fungible', async () => {254 it( 'transferFrom burnt token before approve Fungible', async () => {
255 await usingApi(async () => {255 await usingApi(async () => {
256 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});256 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
257 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');257 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
272 });272 });
273 });273 });
274 274
275 it.only( 'transferFrom burnt token after approve NFT', async () => {275 it( 'transferFrom burnt token after approve NFT', async () => {
276 await usingApi(async () => {276 await usingApi(async () => {
277 // nft277 // nft
278 const nftCollectionId = await createCollectionExpectSuccess();278 const nftCollectionId = await createCollectionExpectSuccess();
282 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1); 282 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
283 });283 });
284 });284 });
285 it.only( 'transferFrom burnt token after approve Fungible', async () => {285 it( 'transferFrom burnt token after approve Fungible', async () => {
286 await usingApi(async () => {286 await usingApi(async () => {
287 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});287 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
288 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');288 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
292 292
293 });293 });
294 }); 294 });
295 it.only( 'transferFrom burnt token after approve ReFungible', async () => {295 it( 'transferFrom burnt token after approve ReFungible', async () => {
296 await usingApi(async () => {296 await usingApi(async () => {
297 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});297 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
298 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');298 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
299 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);299 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
300 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);300 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 100);
301 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);301 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
302 302
303 });303 });