git.delta.rocks / unique-network / refs/commits / 6b16ace53bf5

difftreelog

Tests updated

str-mv2021-08-13parent: #7c95ae9.patch.diff
in: master

2 files changed

modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
15 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';
1925
20chai.use(chaiAsPromised);26chai.use(chaiAsPromised);
53 await submitTransactionAsync(alice, changeOwnerTx);59 await submitTransactionAsync(alice, changeOwnerTx);
5460
55 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;
5763
58 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);
170176
171 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;
173179
174 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);
176182
177 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');
180186
181 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;
194200
195 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});
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1006 });1006 });
1007}1007}
1008
1009export async function setPublicAccessModeExpectFail(
1010 sender: IKeyringPair, collectionId: number,
1011 accessMode: 'Normal' | 'WhiteList',
1012) {
1013 await usingApi(async (api) => {
1014
1015 // Run the transaction
1016 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);
1017 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1018 const result = getGenericResult(events);
1019
1020 // What to expect
1021 // tslint:disable-next-line:no-unused-expression
1022 expect(result.success).to.be.false;
1023 });
1024}
10081025
1009export 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}
1029
1030export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {
1031 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');
1032}
10121033
1013export 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');