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.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 { IKeyringPair } from '@polkadot/types/types';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import usingApi from './substrate/substrate-api';11import {12 burnItemExpectSuccess,13 createCollectionExpectSuccess,14 createItemExpectSuccess,15 destroyCollectionExpectSuccess,16 findNotExistingCollection,17 setVariableMetaDataExpectFailure,18 setVariableMetaDataExpectSuccess,19 addCollectionAdminExpectSuccess,20 setMetadataUpdatePermissionFlagExpectSuccess,21} from './util/helpers';2223chai.use(chaiAsPromised);24const expect = chai.expect;2526describe('Integration Test setVariableMetaData', () => {27 const data = [1, 2, 254, 255];2829 let alice: IKeyringPair;30 let collectionId: number;31 let tokenId: number;32 before(async () => {33 await usingApi(async () => {34 alice = privateKey('//Alice');35 collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });36 tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');37 });38 });3940 it('execute setVariableMetaData', async () => {41 await setVariableMetaDataExpectSuccess(alice, collectionId, tokenId, data);42 });4344 it('verify data was set', async () => {45 await usingApi(async api => {46 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();4748 expect(Array.from(item.VariableData)).to.deep.equal(Array.from(data));49 });50 });51});5253describe('Integration Test collection admin setVariableMetaData', () => {54 const data = [1, 2, 254, 255];5556 let alice: IKeyringPair;57 let bob: IKeyringPair;58 let collectionId: number;59 let tokenId: number;60 before(async () => {61 await usingApi(async () => {62 alice = privateKey('//Alice');63 bob = privateKey('//Bob');64 collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });65 tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');66 await setMetadataUpdatePermissionFlagExpectSuccess(alice, collectionId, 'Admin');67 await addCollectionAdminExpectSuccess(alice, collectionId, bob);68 });69 });7071 it('execute setVariableMetaData', async () => {72 await setVariableMetaDataExpectSuccess(bob, collectionId, tokenId, data);73 });7475 it('verify data was set', async () => {76 await usingApi(async api => {77 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();7879 expect(Array.from(item.VariableData)).to.deep.equal(Array.from(data));80 });81 });82});8384describe('Negative Integration Test setVariableMetaData', () => {85 const data = [1];8687 let alice: IKeyringPair;88 let bob: IKeyringPair;8990 let validCollectionId: number;91 let validTokenId: number;9293 before(async () => {94 await usingApi(async () => {95 alice = privateKey('//Alice');96 bob = privateKey('//Bob');9798 validCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });99 validTokenId = await createItemExpectSuccess(alice, validCollectionId, 'NFT');100 });101 });102103 it('fails on not existing collection id', async () => {104 await usingApi(async api => {105 const nonExistingCollectionId = await findNotExistingCollection(api);106 await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data);107 });108 });109 it('fails on removed collection id', async () => {110 const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });111 const removedCollectionTokenId = await createItemExpectSuccess(alice, removedCollectionId, 'NFT');112113 await destroyCollectionExpectSuccess(removedCollectionId);114 await setVariableMetaDataExpectFailure(alice, removedCollectionId, removedCollectionTokenId, data);115 });116 it('fails on removed token', async () => {117 const removedTokenCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });118 const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT');119 await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId, alice);120121 await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data);122 });123 it('fails on not existing token', async () => {124 const nonExistingTokenId = validTokenId + 1;125126 await setVariableMetaDataExpectFailure(alice, validCollectionId, nonExistingTokenId, data);127 });128 it('fails on too long data', async () => {129 const tooLongData = new Array(4097).fill(0xff);130131 await setVariableMetaDataExpectFailure(alice, validCollectionId, validTokenId, tooLongData);132 });133 it('fails on fungible token', async () => {134 const fungibleCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });135 const fungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');136137 await setVariableMetaDataExpectFailure(alice, fungibleCollectionId, fungibleTokenId, data);138 });139 it('fails on bad sender', async () => {140 await setVariableMetaDataExpectFailure(bob, validCollectionId, validTokenId, data);141 });142});tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -184,22 +184,22 @@
1,
);
});
- it('Transfer with deleted item_id', async () => {
+ it.only('Transfer with deleted item_id', async () => {
// 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 transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, Alice, 10);
+ await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);
await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
// reFungible
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 transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
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