git.delta.rocks / unique-network / refs/commits / 9f99a88f6be8

difftreelog

tests: add setMintPermission helpers

Yaroslav Bolyukin2021-01-26parent: #8e3de77.patch.diff
in: master

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
606 });606 });
607}607}
608608
609export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {609export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {
610 await usingApi(async (api) => {610 await usingApi(async (api) => {
611611
612 // Run the transaction612 // Run the transaction
613 const tx = api.tx.nft.setMintPermission(collectionId, true);613 const tx = api.tx.nft.setMintPermission(collectionId, enabled);
614 const events = await submitTransactionAsync(sender, tx);614 const events = await submitTransactionAsync(sender, tx);
615 const result = getGenericResult(events);615 const result = getGenericResult(events);
616616
617 // Get the collection617 // Get the collection
618 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();618 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
619619
620 // What to expect620 // What to expect
621 // tslint:disable-next-line:no-unused-expression
621 expect(result.success).to.be.true;622 expect(result.success).to.be.true;
622 expect(collection.MintMode).to.be.equal(true);623 expect(collection.MintMode).to.be.equal(enabled);
623 });624 });
624}625}
626
627export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {
628 await setMintPermissionExpectSuccess(sender, collectionId, true);
629}
630
631export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {
632 await usingApi(async (api) => {
633 // Run the transaction
634 const tx = api.tx.nft.setMintPermission(collectionId, enabled);
635 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
636 const result = getCreateCollectionResult(events);
637 // tslint:disable-next-line:no-unused-expression
638 expect(result.success).to.be.false;
639 });
640}
625641
626export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {642export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {
627 await usingApi(async (api) => {643 await usingApi(async (api) => {