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
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -1006,10 +1006,31 @@
   });
 }
 
+export async function setPublicAccessModeExpectFail(
+  sender: IKeyringPair, collectionId: number,
+  accessMode: 'Normal' | 'WhiteList',
+) {
+  await usingApi(async (api) => {
+
+    // Run the transaction
+    const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);
+    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+    const result = getGenericResult(events);
+
+    // What to expect
+    // tslint:disable-next-line:no-unused-expression
+    expect(result.success).to.be.false;
+  });
+}
+
 export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
   await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');
 }
 
+export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {
+  await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');
+}
+
 export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
   await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');
 }