difftreelog
Tests updated
in: master
2 files changed
tests/src/change-collection-owner.test.tsdiffbeforeafterboth15 enableWhiteListExpectSuccess,15 enableWhiteListExpectSuccess,16 setMintPermissionExpectSuccess,16 setMintPermissionExpectSuccess,17 destroyCollectionExpectSuccess,17 destroyCollectionExpectSuccess,18 setCollectionSponsorExpectFailure,19 confirmSponsorshipExpectFailure,20 removeCollectionSponsorExpectFailure,21 enableWhiteListExpectFail,22 setMintPermissionExpectFailure,23 destroyCollectionExpectFailure,18} from './util/helpers';24} from './util/helpers';192520chai.use(chaiAsPromised);26chai.use(chaiAsPromised);53 await submitTransactionAsync(alice, changeOwnerTx);59 await submitTransactionAsync(alice, changeOwnerTx);546055 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);61 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);56 await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;62 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;576358 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();64 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();59 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);65 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);169 await submitTransactionAsync(alice, changeOwnerTx);175 await submitTransactionAsync(alice, changeOwnerTx);170176171 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);177 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);172 await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;178 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;173179174 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();180 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();175 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);181 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);176182177 await expect(setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Alice')).to.be.rejected;183 await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');178 await expect(confirmSponsorshipExpectSuccess(collectionId, '//Alice')).to.be.rejected;184 await confirmSponsorshipExpectFailure(collectionId, '//Alice');179 await expect(removeCollectionSponsorExpectSuccess(collectionId, '//Alice')).to.be.rejected;185 await removeCollectionSponsorExpectFailure(collectionId, '//Alice');180186181 const collectionLimits = {187 const collectionLimits = {182 AccountTokenOwnershipLimit: 1,188 AccountTokenOwnershipLimit: 1,190 collectionId,196 collectionId,191 collectionLimits,197 collectionLimits,192 );198 );193 await expect(submitTransactionAsync(alice, tx1)).to.be.rejected;199 await expect(submitTransactionExpectFailAsync(alice, tx1)).to.be.rejected;194200195 await expect(enableWhiteListExpectSuccess(alice, collectionId)).to.be.rejected;201 await enableWhiteListExpectFail(alice, collectionId);196 await expect(setMintPermissionExpectSuccess(alice, collectionId, true)).to.be.rejected;202 await setMintPermissionExpectFailure(alice, collectionId, true);197 await expect(destroyCollectionExpectSuccess(collectionId, '//Alice')).to.be.rejected;203 await destroyCollectionExpectFailure(collectionId, '//Alice');198 });204 });199 });205 });200});206});tests/src/util/helpers.tsdiffbeforeafterboth1006 });1006 });1007}1007}10081009export async function setPublicAccessModeExpectFail(1010 sender: IKeyringPair, collectionId: number,1011 accessMode: 'Normal' | 'WhiteList',1012) {1013 await usingApi(async (api) => {10141015 // Run the transaction1016 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);1017 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1018 const result = getGenericResult(events);10191020 // What to expect1021 // tslint:disable-next-line:no-unused-expression1022 expect(result.success).to.be.false;1023 });1024}100810251009export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1026export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1010 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1027 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1011}1028}10291030export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {1031 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');1032}101210331013export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1034export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1014 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1035 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');