difftreelog
fix test after burtItem redesign (partially)
in: master
7 files changed
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -38,7 +38,7 @@
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
// Get the item
@@ -59,7 +59,7 @@
await usingApi(async (api) => {
// Destroy 1 of 10
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
@@ -79,7 +79,7 @@
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
@@ -92,7 +92,7 @@
});
});
- it('Burn owned portion of item in ReFungible collection', async () => {
+ it.only('Burn owned portion of item in ReFungible collection', async () => {
const createMode = 'ReFungible';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
@@ -107,7 +107,7 @@
const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
// Bob burns his portion
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(bob.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events2 = await submitTransactionAsync(bob, tx);
const result2 = getGenericResult(events2);
@@ -152,7 +152,7 @@
await addCollectionAdminExpectSuccess(alice, collectionId, bob);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events = await submitTransactionAsync(bob, tx);
const result = getGenericResult(events);
// Get the item
@@ -166,7 +166,7 @@
});
- it('Burn item in Fungible collection', async () => {
+ it.only('Burn item in Fungible collection', async () => {
const createMode = 'Fungible';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
@@ -175,7 +175,7 @@
await usingApi(async (api) => {
// Destroy 1 of 10
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(bob, tx);
const result = getGenericResult(events);
@@ -189,14 +189,14 @@
});
});
- it('Burn item in ReFungible collection', async () => {
+ it.only('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await addCollectionAdminExpectSuccess(alice, collectionId, bob);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(bob, tx);
const result = getGenericResult(events);
// Get alice balance
@@ -225,7 +225,7 @@
await destroyCollectionExpectSuccess(collectionId);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(alice, tx);
};
@@ -240,7 +240,7 @@
const tokenId = 10;
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(alice, tx);
};
@@ -255,7 +255,7 @@
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(bob, tx);
};
@@ -271,7 +271,7 @@
await usingApi(async (api) => {
- const burntx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
+ const burntx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events1 = await submitTransactionAsync(alice, burntx);
const result1 = getGenericResult(events1);
expect(result1.success).to.be.true;
@@ -294,7 +294,7 @@
await usingApi(async (api) => {
// Destroy 11 of 10
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 11);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 11);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(alice, tx);
};
tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/burnItemEvent.test.ts
+++ b/tests/src/check-event/burnItemEvent.test.ts
@@ -29,7 +29,7 @@
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');
- const burnItem = api.tx.nft.burnItem(collectionID, itemID, normalizeAccountId(Alice.address), 1);
+ const burnItem = api.tx.nft.burnItem(collectionID, itemID, 1);
const events = await submitTransactionAsync(Alice, burnItem);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerTake.test.ts
+++ b/tests/src/collision-tests/admVsOwnerTake.test.ts
@@ -34,7 +34,7 @@
const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
//
const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);
- const burnItem = api.tx.nft.burnItem(collectionId, itemId, normalizeAccountId(Alice.address), 1);
+ const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);
await Promise.all([
sendItem.signAndSend(Bob),
burnItem.signAndSend(Alice),
tests/src/setVariableMetaData.test.tsdiffbeforeafterboth--- a/tests/src/setVariableMetaData.test.ts
+++ b/tests/src/setVariableMetaData.test.ts
@@ -116,7 +116,7 @@
it('fails on removed token', async () => {
const removedTokenCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT');
- await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId, alice);
+ await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId);
await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data);
});
tests/src/transfer.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import { expect } from 'chai';9import { alicesPublicKey, bobsPublicKey } from './accounts';10import getBalance from './substrate/get-balance';11import privateKey from './substrate/privateKey';12import { default as usingApi, submitTransactionAsync } from './substrate/substrate-api';13import {14 burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,15 destroyCollectionExpectSuccess,16 findUnusedAddress,17 getCreateCollectionResult,18 getCreateItemResult,19 transferExpectFailure,20 transferExpectSuccess,21 addCollectionAdminExpectSuccess,22} from './util/helpers';2324let Alice: IKeyringPair;25let Bob: IKeyringPair;26let Charlie: IKeyringPair;2728describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {29 it('Balance transfers and check balance', async () => {30 await usingApi(async (api: ApiPromise) => {31 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);3233 const alicePrivateKey = privateKey('//Alice');3435 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);36 const events = await submitTransactionAsync(alicePrivateKey, transfer);37 const result = getCreateItemResult(events);38 // tslint:disable-next-line:no-unused-expression39 expect(result.success).to.be.true;4041 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);4243 // tslint:disable-next-line:no-unused-expression44 expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;45 // tslint:disable-next-line:no-unused-expression46 expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;47 });48 });4950 it('Inability to pay fees error message is correct', async () => {51 await usingApi(async (api) => {52 // Find unused address53 const pk = await findUnusedAddress(api);5455 const badTransfer = api.tx.balances.transfer(bobsPublicKey, 1n);56 // const events = await submitTransactionAsync(pk, badTransfer);57 const badTransaction = async () => {58 const events = await submitTransactionAsync(pk, badTransfer);59 const result = getCreateCollectionResult(events);60 // tslint:disable-next-line:no-unused-expression61 expect(result.success).to.be.false;62 };63 await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees , e.g. account balance too low');64 });65 });6667 it('User can transfer owned token', async () => {68 await usingApi(async () => {69 const Alice = privateKey('//Alice');70 const Bob = privateKey('//Bob');71 // nft72 const nftCollectionId = await createCollectionExpectSuccess();73 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');74 await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');75 // fungible76 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});77 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');78 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');79 // reFungible80 const reFungibleCollectionId = await81 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});82 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');83 await transferExpectSuccess(84 reFungibleCollectionId,85 newReFungibleTokenId,86 Alice,87 Bob,88 100,89 'ReFungible',90 );91 });92 });9394 it('Collection admin can transfer owned token', async () => {95 await usingApi(async () => {96 const Alice = privateKey('//Alice');97 const Bob = privateKey('//Bob');98 // nft99 const nftCollectionId = await createCollectionExpectSuccess();100 await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);101 const newNftTokenId = await createItemExpectSuccess(Bob, nftCollectionId, 'NFT', Bob.address);102 await transferExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, 1, 'NFT');103 // fungible104 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});105 await addCollectionAdminExpectSuccess(Alice, fungibleCollectionId, Bob);106 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible', Bob.address);107 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, 1, 'Fungible');108 // reFungible109 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});110 await addCollectionAdminExpectSuccess(Alice, reFungibleCollectionId, Bob);111 const newReFungibleTokenId = await createItemExpectSuccess(Bob, reFungibleCollectionId, 'ReFungible', Bob.address);112 await transferExpectSuccess(113 reFungibleCollectionId,114 newReFungibleTokenId,115 Bob,116 Alice,117 100,118 'ReFungible',119 );120 });121 });122});123124describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {125 before(async () => {126 await usingApi(async () => {127 Alice = privateKey('//Alice');128 Bob = privateKey('//Bob');129 Charlie = privateKey('//Charlie');130 });131 });132 it('Transfer with not existed collection_id', async () => {133 await usingApi(async (api) => {134 // nft135 const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;136 await transferExpectFailure(nftCollectionCount + 1, 1, Alice, Bob, 1);137 // fungible138 const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;139 await transferExpectFailure(fungibleCollectionCount + 1, 1, Alice, Bob, 1);140 // reFungible141 const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;142 await transferExpectFailure(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);143 });144 });145 it('Transfer with deleted collection_id', async () => {146 // nft147 const nftCollectionId = await createCollectionExpectSuccess();148 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');149 await destroyCollectionExpectSuccess(nftCollectionId);150 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);151 // fungible152 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});153 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');154 await destroyCollectionExpectSuccess(fungibleCollectionId);155 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);156 // reFungible157 const reFungibleCollectionId = await158 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});159 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');160 await destroyCollectionExpectSuccess(reFungibleCollectionId);161 await transferExpectFailure(162 reFungibleCollectionId,163 newReFungibleTokenId,164 Alice,165 Bob,166 1,167 );168 });169 it('Transfer with not existed item_id', async () => {170 // nft171 const nftCollectionId = await createCollectionExpectSuccess();172 await transferExpectFailure(nftCollectionId, 2, Alice, Bob, 1);173 // fungible174 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});175 await transferExpectFailure(fungibleCollectionId, 2, Alice, Bob, 1);176 // reFungible177 const reFungibleCollectionId = await178 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});179 await transferExpectFailure(180 reFungibleCollectionId,181 2,182 Alice,183 Bob,184 1,185 );186 });187 it('Transfer with deleted item_id', async () => {188 // nft189 const nftCollectionId = await createCollectionExpectSuccess();190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');191 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);192 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);193 // fungible194 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});195 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');196 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, Alice, 10);197 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);198 // reFungible199 const reFungibleCollectionId = await200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);203 await transferExpectFailure(204 reFungibleCollectionId,205 newReFungibleTokenId,206 Alice,207 Bob,208 1,209 );210 });211 it('Transfer with recipient that is not owner', async () => {212 // nft213 const nftCollectionId = await createCollectionExpectSuccess();214 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');215 await transferExpectFailure(nftCollectionId, newNftTokenId, Charlie, Bob, 1);216 // fungible217 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});218 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');219 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1);220 // reFungible221 const reFungibleCollectionId = await222 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});223 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');224 await transferExpectFailure(225 reFungibleCollectionId,226 newReFungibleTokenId,227 Charlie,228 Bob,229 1,230 );231 });232});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise } from '@polkadot/api';7import { IKeyringPair } from '@polkadot/types/types';8import { expect } from 'chai';9import { alicesPublicKey, bobsPublicKey } from './accounts';10import getBalance from './substrate/get-balance';11import privateKey from './substrate/privateKey';12import { default as usingApi, submitTransactionAsync } from './substrate/substrate-api';13import {14 burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,15 destroyCollectionExpectSuccess,16 findUnusedAddress,17 getCreateCollectionResult,18 getCreateItemResult,19 transferExpectFailure,20 transferExpectSuccess,21 addCollectionAdminExpectSuccess,22} from './util/helpers';2324let Alice: IKeyringPair;25let Bob: IKeyringPair;26let Charlie: IKeyringPair;2728describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {29 it('Balance transfers and check balance', async () => {30 await usingApi(async (api: ApiPromise) => {31 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);3233 const alicePrivateKey = privateKey('//Alice');3435 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);36 const events = await submitTransactionAsync(alicePrivateKey, transfer);37 const result = getCreateItemResult(events);38 // tslint:disable-next-line:no-unused-expression39 expect(result.success).to.be.true;4041 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);4243 // tslint:disable-next-line:no-unused-expression44 expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;45 // tslint:disable-next-line:no-unused-expression46 expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;47 });48 });4950 it('Inability to pay fees error message is correct', async () => {51 await usingApi(async (api) => {52 // Find unused address53 const pk = await findUnusedAddress(api);5455 const badTransfer = api.tx.balances.transfer(bobsPublicKey, 1n);56 // const events = await submitTransactionAsync(pk, badTransfer);57 const badTransaction = async () => {58 const events = await submitTransactionAsync(pk, badTransfer);59 const result = getCreateCollectionResult(events);60 // tslint:disable-next-line:no-unused-expression61 expect(result.success).to.be.false;62 };63 await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees , e.g. account balance too low');64 });65 });6667 it('User can transfer owned token', async () => {68 await usingApi(async () => {69 const Alice = privateKey('//Alice');70 const Bob = privateKey('//Bob');71 // nft72 const nftCollectionId = await createCollectionExpectSuccess();73 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');74 await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');75 // fungible76 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});77 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');78 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');79 // reFungible80 const reFungibleCollectionId = await81 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});82 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');83 await transferExpectSuccess(84 reFungibleCollectionId,85 newReFungibleTokenId,86 Alice,87 Bob,88 100,89 'ReFungible',90 );91 });92 });9394 it('Collection admin can transfer owned token', async () => {95 await usingApi(async () => {96 const Alice = privateKey('//Alice');97 const Bob = privateKey('//Bob');98 // nft99 const nftCollectionId = await createCollectionExpectSuccess();100 await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);101 const newNftTokenId = await createItemExpectSuccess(Bob, nftCollectionId, 'NFT', Bob.address);102 await transferExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, 1, 'NFT');103 // fungible104 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});105 await addCollectionAdminExpectSuccess(Alice, fungibleCollectionId, Bob);106 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible', Bob.address);107 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, 1, 'Fungible');108 // reFungible109 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});110 await addCollectionAdminExpectSuccess(Alice, reFungibleCollectionId, Bob);111 const newReFungibleTokenId = await createItemExpectSuccess(Bob, reFungibleCollectionId, 'ReFungible', Bob.address);112 await transferExpectSuccess(113 reFungibleCollectionId,114 newReFungibleTokenId,115 Bob,116 Alice,117 100,118 'ReFungible',119 );120 });121 });122});123124describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {125 before(async () => {126 await usingApi(async () => {127 Alice = privateKey('//Alice');128 Bob = privateKey('//Bob');129 Charlie = privateKey('//Charlie');130 });131 });132 it('Transfer with not existed collection_id', async () => {133 await usingApi(async (api) => {134 // nft135 const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;136 await transferExpectFailure(nftCollectionCount + 1, 1, Alice, Bob, 1);137 // fungible138 const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;139 await transferExpectFailure(fungibleCollectionCount + 1, 1, Alice, Bob, 1);140 // reFungible141 const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;142 await transferExpectFailure(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);143 });144 });145 it('Transfer with deleted collection_id', async () => {146 // nft147 const nftCollectionId = await createCollectionExpectSuccess();148 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');149 await destroyCollectionExpectSuccess(nftCollectionId);150 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);151 // fungible152 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});153 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');154 await destroyCollectionExpectSuccess(fungibleCollectionId);155 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);156 // reFungible157 const reFungibleCollectionId = await158 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});159 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');160 await destroyCollectionExpectSuccess(reFungibleCollectionId);161 await transferExpectFailure(162 reFungibleCollectionId,163 newReFungibleTokenId,164 Alice,165 Bob,166 1,167 );168 });169 it('Transfer with not existed item_id', async () => {170 // nft171 const nftCollectionId = await createCollectionExpectSuccess();172 await transferExpectFailure(nftCollectionId, 2, Alice, Bob, 1);173 // fungible174 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});175 await transferExpectFailure(fungibleCollectionId, 2, Alice, Bob, 1);176 // reFungible177 const reFungibleCollectionId = await178 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});179 await transferExpectFailure(180 reFungibleCollectionId,181 2,182 Alice,183 Bob,184 1,185 );186 });187 it.only('Transfer with deleted item_id', async () => {188 // nft189 const nftCollectionId = await createCollectionExpectSuccess();190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');191 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);192 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);193 // fungible194 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});195 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');196 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);197 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);198 // reFungible199 const reFungibleCollectionId = await200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);203 await transferExpectFailure(204 reFungibleCollectionId,205 newReFungibleTokenId,206 Alice,207 Bob,208 1,209 );210 });211 it('Transfer with recipient that is not owner', async () => {212 // nft213 const nftCollectionId = await createCollectionExpectSuccess();214 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');215 await transferExpectFailure(nftCollectionId, newNftTokenId, Charlie, Bob, 1);216 // fungible217 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});218 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');219 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1);220 // reFungible221 const reFungibleCollectionId = await222 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});223 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');224 await transferExpectFailure(225 reFungibleCollectionId,226 newReFungibleTokenId,227 Charlie,228 Bob,229 1,230 );231 });232});tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -246,16 +246,16 @@
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);
+ await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
await approveExpectFail(nftCollectionId, newNftTokenId, Alice, Bob);
await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
});
});
- it( 'transferFrom burnt token before approve Fungible', async () => {
+ it.only( 'transferFrom burnt token before approve Fungible', async () => {
await usingApi(async () => {
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, Alice, 10);
+ await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
@@ -265,39 +265,39 @@
await usingApi(async () => {
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);
+ await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
});
});
- it( 'transferFrom burnt token after approve NFT', async () => {
+ it.only( 'transferFrom burnt token after approve NFT', async () => {
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);
+ await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
});
});
- it( 'transferFrom burnt token after approve Fungible', async () => {
+ it.only( 'transferFrom burnt token after approve Fungible', async () => {
await usingApi(async () => {
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, Alice, 10);
+ await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
});
});
- it( 'transferFrom burnt token after approve ReFungible', async () => {
+ it.only( 'transferFrom burnt token after approve ReFungible', async () => {
await usingApi(async () => {
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);
+ await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -700,9 +700,9 @@
ReFungible: CreateReFungibleData;
};
-export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, owner: IKeyringPair, value = 0) {
+export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 0) {
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(owner.address), value);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, value);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
// Get the item