difftreelog
Missing tests added
in: master
6 files changed
tests/src/addToWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToWhiteList.test.ts
+++ b/tests/src/addToWhiteList.test.ts
@@ -17,6 +17,7 @@
enableWhiteListExpectSuccess,
normalizeAccountId,
addCollectionAdminExpectSuccess,
+ addToWhiteListExpectFail,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -98,6 +99,11 @@
});
});
+ it('Add to the white list by regular user', async () => {
+ const collectionId = await createCollectionExpectSuccess();
+ await addToWhiteListExpectFail(Bob, collectionId, Charlie.address);
+ });
+
it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {
const collectionId = await createCollectionExpectSuccess();
await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -37,6 +37,33 @@
});
});
+ it('Remove collection admin by admin.', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const collectionId = await createCollectionExpectSuccess();
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ expect(collection.Owner).to.be.deep.eq(Alice.address);
+ // first - add collection admin Bob
+ const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
+ await submitTransactionAsync(Alice, addAdminTx);
+
+ const addAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));
+ await submitTransactionAsync(Alice, addAdminTx2);
+
+ const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON();
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(Bob.address));
+
+ // then remove bob from admins of collection
+ const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
+ await submitTransactionAsync(Charlie, removeAdminTx);
+
+ const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON;
+ expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(Bob.address));
+ });
+ });
+
it('Remove admin from collection that has no admins', async () => {
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
tests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionSponsor.test.ts
+++ b/tests/src/removeCollectionSponsor.test.ts
@@ -112,6 +112,12 @@
await removeCollectionSponsorExpectFailure(collectionId, '//Bob');
});
+ it('(!negative test!) Remove sponsor for a collection by regular user', async () => {
+ const collectionId = await createCollectionExpectSuccess();
+ await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+ await removeCollectionSponsorExpectFailure(collectionId, '//Bob');
+ });
+
it('(!negative test!) Remove sponsor in a destroyed collection', async () => {
const collectionId = await createCollectionExpectSuccess();
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromWhiteList.test.ts
+++ b/tests/src/removeFromWhiteList.test.ts
@@ -124,4 +124,13 @@
await removeFromWhiteListExpectSuccess(bob, collectionWithoutWhitelistId, normalizeAccountId(charlie.address));
});
});
+
+ it('Regular user can`t remove from whitelist', async () => {
+ await usingApi(async () => {
+ const collectionWithoutWhitelistId = await createCollectionExpectSuccess();
+ await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);
+ await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, charlie.address);
+ await removeFromWhiteListExpectFailure(bob, collectionWithoutWhitelistId, normalizeAccountId(charlie.address));
+ });
+ });
});
\ No newline at end of file
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth--- a/tests/src/setSchemaVersion.test.ts
+++ b/tests/src/setSchemaVersion.test.ts
@@ -24,6 +24,7 @@
let alice: IKeyringPair;
let bob: IKeyringPair;
+let charlie: IKeyringPair;
let collectionIdForTesting: number;
/*
@@ -111,12 +112,13 @@
});
});
-describe('setSchemaVersion negative', () => {
+describe.only('setSchemaVersion negative', () => {
let tx;
before(async () => {
await usingApi(async () => {
const keyring = new Keyring({ type: 'sr25519' });
alice = keyring.addFromUri('//Alice');
+ charlie = keyring.addFromUri('//Charlie');
});
});
it('execute setSchemaVersion for not exists collection', async () => {
@@ -127,7 +129,6 @@
await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
-
it('execute setSchemaVersion with not correct schema version', async () => {
await usingApi(async (api: ApiPromise) => {
const consoleError = console.error;
@@ -143,7 +144,6 @@
}
});
});
-
it('execute setSchemaVersion for deleted collection', async () => {
await usingApi(async (api: ApiPromise) => {
await destroyCollectionExpectSuccess(collectionIdForTesting);
@@ -151,4 +151,10 @@
await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
+ it('Regular user can`t execute setSchemaVersion with image url and unique ', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');
+ await expect(submitTransactionAsync(charlie, tx)).to.be.rejected;
+ });
+ });
});
tests/src/util/helpers.tsdiffbeforeafterboth1088 });1088 });1089}1089}10901091export async function addToWhiteListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1092 await usingApi(async (api) => {1093 // Run the transaction1094 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1095 const events = await expect(submitTransactionAsync(sender, tx)).to.be.rejected;1096 const result = getGenericResult(events);10971098 // What to expect1099 // tslint:disable-next-line:no-unused-expression1100 expect(result.success).to.be.false;1101 });1102}109011031091export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1104export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1092 await usingApi(async (api) => {1105 await usingApi(async (api) => {