difftreelog
Collision tests fixed
in: master
10 files changed
tests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerChanges.test.ts
+++ b/tests/src/collision-tests/admVsOwnerChanges.test.ts
@@ -4,8 +4,13 @@
import privateKey from '../substrate/privateKey';
import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
import {
+ addCollectionAdminExpectSuccess,
+ approveExpectSuccess,
createCollectionExpectSuccess,
createItemExpectSuccess,
+ transferFromExpectSuccess,
+ transferExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -25,18 +30,19 @@
describe('Admin vs Owner changes token: ', () => {
// tslint:disable-next-line: max-line-length
it('The collection admin changes the owner of the token and in the same block the current owner transfers the token to another address ', async () => {
+
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTxBob);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
- const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);
+ const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));
await submitTransactionAsync(Bob, changeAdminTxFerdie);
const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');
- //
- const changeOwner = api.tx.nft.transferFrom(Ferdie.address, Bob.address, collectionId, itemId, 1);
- const approve = api.tx.nft.approve(Bob.address, collectionId, itemId, 1);
- const sendItem = api.tx.nft.transfer(Alice.address, collectionId, itemId, 1);
+
+ const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);
+ const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);
+ const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);
await Promise.all([
changeOwner.signAndSend(Alice),
approve.signAndSend(Bob),
tests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerData.test.ts
+++ b/tests/src/collision-tests/admVsOwnerData.test.ts
@@ -6,6 +6,7 @@
import {
createCollectionExpectSuccess,
createItemExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -26,7 +27,7 @@
const AliceData = 1;
const BobData = 2;
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTx);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerTake.test.ts
+++ b/tests/src/collision-tests/admVsOwnerTake.test.ts
@@ -6,6 +6,7 @@
import {
createCollectionExpectSuccess,
createItemExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -27,18 +28,18 @@
it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTx);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
//
- const sendItem = api.tx.nft.transfer(Ferdie.address, collectionId, itemId, 1);
+ const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);
const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);
await Promise.all([
sendItem.signAndSend(Bob),
burnItem.signAndSend(Alice),
]);
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
let itemBurn = false;
itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;
// tslint:disable-next-line: no-unused-expression
tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/adminDestroyCollection.test.ts
+++ b/tests/src/collision-tests/adminDestroyCollection.test.ts
@@ -5,6 +5,7 @@
import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
import {
createCollectionExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -26,12 +27,12 @@
it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTx);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
await timeoutPromise(10000);
//
- const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, Ferdie.address);
+ const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));
const destroyCollection = api.tx.nft.destroyCollection(collectionId);
await Promise.all([
addWhitelistAdm.signAndSend(Bob),
tests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8 createCollectionExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13let Alice: IKeyringPair;14let Bob: IKeyringPair;15let Ferdie: IKeyringPair;16let Charlie: IKeyringPair;17let Eve: IKeyringPair;18let Dave: IKeyringPair;1920before(async () => {21 await usingApi(async () => {22 Alice = privateKey('//Alice');23 Bob = privateKey('//Bob');24 Ferdie = privateKey('//Ferdie');25 Charlie = privateKey('//Charlie');26 Eve = privateKey('//Eve');27 Dave = privateKey('//Dave');28 });29});3031describe('Admin limit exceeded collection: ', () => {32 // tslint:disable-next-line: max-line-length33 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {34 await usingApi(async (api) => {35 const collectionId = await createCollectionExpectSuccess();3637 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();38 expect(chainAdminLimit).to.be.equal(5);3940 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, Eve.address);41 await submitTransactionAsync(Alice, changeAdminTx1);42 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, Dave.address);43 await submitTransactionAsync(Alice, changeAdminTx2);44 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);45 await submitTransactionAsync(Alice, changeAdminTx3);4647 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));48 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, Ferdie.address);49 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);50 await Promise.all([51 addAdmOne.signAndSend(Bob),52 addAdmTwo.signAndSend(Alice),53 ]);54 await timeoutPromise(10000);55 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, Alice.address);56 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5758 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));59 expect(adminListAfterAddAdmin).to.be.contains(Eve.address);60 expect(adminListAfterAddAdmin).to.be.contains(Ferdie.address);61 expect(adminListAfterAddAdmin).not.to.be.contains(Alice.address);62 await timeoutPromise(20000);63 });64 });65});1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8 createCollectionExpectSuccess,9 normalizeAccountId,10} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;16let Ferdie: IKeyringPair;17let Charlie: IKeyringPair;18let Eve: IKeyringPair;19let Dave: IKeyringPair;2021before(async () => {22 await usingApi(async () => {23 Alice = privateKey('//Alice');24 Bob = privateKey('//Bob');25 Ferdie = privateKey('//Ferdie');26 Charlie = privateKey('//Charlie');27 Eve = privateKey('//Eve');28 Dave = privateKey('//Dave');29 });30});3132describe('Admin limit exceeded collection: ', () => {33 // tslint:disable-next-line: max-line-length34 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {35 await usingApi(async (api) => {36 const collectionId = await createCollectionExpectSuccess();3738 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();39 expect(chainAdminLimit).to.be.equal(5);4041 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));42 await submitTransactionAsync(Alice, changeAdminTx1);43 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));44 await submitTransactionAsync(Alice, changeAdminTx2);45 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));46 await submitTransactionAsync(Alice, changeAdminTx3);4748 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));49 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));50 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));51 await Promise.all([52 addAdmOne.signAndSend(Bob),53 addAdmTwo.signAndSend(Alice),54 ]);55 await timeoutPromise(20000);56 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));57 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;5859 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));60 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));61 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));62 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));63 await timeoutPromise(20000);64 });65 });66});tests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/adminRightsOff.test.ts
+++ b/tests/src/collision-tests/adminRightsOff.test.ts
@@ -6,6 +6,7 @@
import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';
import {
createCollectionExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -25,22 +26,22 @@
it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTx);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
await timeoutPromise(10000);
const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
- const addItemAdm = api.tx.nft.createMultipleItems(collectionId, Bob.address, args);
- const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+ const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);
+ const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await Promise.all([
addItemAdm.signAndSend(Bob),
removeAdm.signAndSend(Alice),
]);
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
expect(itemsListIndex.toNumber()).to.be.equal(0);
const adminList: any = (await api.query.nft.adminList(collectionId));
- expect(adminList).not.to.be.contains(Bob.address);
+ expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));
await timeoutPromise(20000);
});
});
tests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/setSponsorNewOwner.test.ts
+++ b/tests/src/collision-tests/setSponsorNewOwner.test.ts
@@ -4,7 +4,9 @@
import privateKey from '../substrate/privateKey';
import usingApi from '../substrate/substrate-api';
import {
- createCollectionExpectSuccess, setCollectionSponsorExpectSuccess,
+ createCollectionExpectSuccess,
+ setCollectionSponsorExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -28,16 +30,16 @@
const collectionId = await createCollectionExpectSuccess();
await setCollectionSponsorExpectSuccess(collectionId, Bob.address);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);
const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);
await Promise.all([
confirmSponsorship.signAndSend(Bob),
changeCollectionOwner.signAndSend(Alice),
]);
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.Sponsorship.Confirmed).to.be.eq(Bob.address);
+ expect(collection.Sponsorship.confirmed).to.be.eq(Bob.address);
expect(collection.Owner).to.be.eq(Ferdie.address);
await timeoutPromise(20000);
});
tests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/sponsorPayments.test.ts
+++ b/tests/src/collision-tests/sponsorPayments.test.ts
@@ -10,6 +10,7 @@
createCollectionExpectSuccess,
createItemExpectSuccess,
setCollectionSponsorExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -29,7 +30,7 @@
it('Payment of commission if one block contains transactions for payment from the sponsor\'s balance and his (sponsor\'s) exclusion from the collection ', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTxBob);
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
@@ -37,7 +38,7 @@
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
- const sendItem = api.tx.nft.transfer(Alice.address, collectionId, itemId, 1);
+ const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);
const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);
await Promise.all([
sendItem.signAndSend(Bob),
tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/tokenLimitsOff.test.ts
+++ b/tests/src/collision-tests/tokenLimitsOff.test.ts
@@ -9,6 +9,7 @@
createCollectionExpectSuccess,
getCreateItemResult,
setMintPermissionExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -57,22 +58,22 @@
// tslint:disable-next-line:no-unused-expression
expect(subTxTesult.success).to.be.true;
const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
const mintItemOne = api.tx.nft
- .createMultipleItems(collectionId, Ferdie.address, args);
+ .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);
const mintItemTwo = api.tx.nft
- .createMultipleItems(collectionId, Bob.address, args);
+ .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);
await Promise.all([
mintItemOne.signAndSend(Ferdie),
mintItemTwo.signAndSend(Bob),
]);
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
// TokenLimit = 4. The first transaction is successful. The second should fail.
- await timeoutPromise(10000);
+ await timeoutPromise(20000);
});
});
});
tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/turnsOffMinting.test.ts
+++ b/tests/src/collision-tests/turnsOffMinting.test.ts
@@ -7,6 +7,7 @@
addToWhiteListExpectSuccess,
createCollectionExpectSuccess,
setMintPermissionExpectSuccess,
+ normalizeAccountId,
} from '../util/helpers';
chai.use(chaiAsPromised);
@@ -30,7 +31,7 @@
await setMintPermissionExpectSuccess(Alice, collectionId, true);
await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);
- const mintItem = api.tx.nft.createItem(collectionId, Ferdie.address, 'NFT');
+ const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');
const offMinting = api.tx.nft.setMintPermission(collectionId, false);
await Promise.all([
mintItem.signAndSend(Ferdie),