difftreelog
Merge pull request #68 from usetech-llc/feature/NFTPAR-234
in: master
Feature/nftpar 234
3 files changed
tests/src/addToWhiteList.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';
2import chai from 'chai';
3import chaiAsPromised from 'chai-as-promised';
4import privateKey from './substrate/privateKey';
5import usingApi, { submitTransactionExpectFailAsync } from './substrate/substrate-api';
6import {
7 addToWhiteListExpectSuccess,
8 createCollectionExpectSuccess,
9 createItemExpectSuccess,
10 destroyCollectionExpectSuccess,
11 enablePublicMintingExpectSuccess,
12 enableWhiteListExpectSuccess,
13} from './util/helpers';
14
15chai.use(chaiAsPromised);
16const expect = chai.expect;
17
18let Alice: IKeyringPair;
19let Bob: IKeyringPair;
20
21describe.only('Integration Test ext. addToWhiteList()', () => {
22
23 before(async () => {
24 await usingApi(async (api) => {
25 Alice = privateKey('//Alice');
26 Bob = privateKey('//Bob');
27 });
28 });
29
30 it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {
31 const collectionId = await createCollectionExpectSuccess();
32 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
33 });
34
35 it('Whitelisted minting: list restrictions', async () => {
36 const collectionId = await createCollectionExpectSuccess();
37 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
38 await enableWhiteListExpectSuccess(Alice, collectionId);
39 await enablePublicMintingExpectSuccess(Alice, collectionId);
40 await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
41 });
42});
43
44describe.only('Negative Integration Test ext. addToWhiteList()', () => {
45
46 it('White list an address in the collection that does not exist', async () => {
47 await usingApi(async (api) => {
48 // tslint:disable-next-line: no-bitwise
49 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
50 const Bob = privateKey('//Bob');
51
52 const tx = api.tx.nft.addToWhiteList(collectionId, Bob.address);
53 await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
54 });
55 });
56
57 it('White list an address in the collection that was destroyed', async () => {
58 await usingApi(async (api) => {
59 const Alice = privateKey('//Alice');
60 const Bob = privateKey('//Bob');
61 // tslint:disable-next-line: no-bitwise
62 const collectionId = await createCollectionExpectSuccess();
63 await destroyCollectionExpectSuccess(collectionId);
64 const tx = api.tx.nft.addToWhiteList(collectionId, Bob.address);
65 await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
66 });
67 });
68
69 it('White list an address in the collection that does not have white list access enabled', async () => {
70 await usingApi(async (api) => {
71 const Alice = privateKey('//Alice');
72 const Ferdie = privateKey('//Ferdie');
73 const collectionId = await createCollectionExpectSuccess();
74 await enableWhiteListExpectSuccess(Alice, collectionId);
75 await enablePublicMintingExpectSuccess(Alice, collectionId);
76 const tx = api.tx.nft.createItem(collectionId, Ferdie.address, 'NFT');
77 await expect(submitTransactionExpectFailAsync(Ferdie, tx)).to.be.rejected;
78 });
79 });
80
81});
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/toggleContractWhiteList.test.ts
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -33,7 +33,7 @@
});
});
- it.only(`Only whitelisted account can call contract`, async () => {
+ it(`Only whitelisted account can call contract`, async () => {
await usingApi(async api => {
const bob = privateKey("//Bob");
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -620,18 +620,22 @@
export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {
await usingApi(async (api) => {
+ const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();
+
// Run the transaction
const tx = api.tx.nft.addToWhiteList(collectionId, address);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
- // Get the collection
- const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+ const whiteListedAfter = (await api.query.nft.whiteList(collectionId, address)).toJSON();
// What to expect
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- expect(collection.MintMode).to.be.equal(true);
+ // tslint:disable-next-line: no-unused-expression
+ expect(whiteListedBefore).to.be.false;
+ // tslint:disable-next-line: no-unused-expression
+ expect(whiteListedAfter).to.be.true;
});
}