difftreelog
CORE-36. Integration tests
in: master
2 files changed
tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import privateKey from './substrate/privateKey';9import usingApi from './substrate/substrate-api';10import {11 createItemExpectSuccess,12 createCollectionExpectSuccess,13 transferExpectSuccess,14 transferExpectFailure,15 setTransferFlagExpectSuccess16} from './util/helpers';1718chai.use(chaiAsPromised);1920describe('Enable/Disable Transfers', () => {21 it.only('User can transfer token with enabled transfer flag', async () => {22 await usingApi(async () => {23 const Alice = privateKey('//Alice');24 const Bob = privateKey('//Bob');25 // nft26 const nftCollectionId = await createCollectionExpectSuccess();27 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');2829 // explicitely set transfer flag30 await setTransferFlagExpectSuccess(Alice, nftCollectionId, true);3132 await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);33 });34 });3536 it.only('User can\'n transfer token with disabled transfer flag', async () => {37 await usingApi(async () => {38 const Alice = privateKey('//Alice');39 const Bob = privateKey('//Bob');40 // nft41 const nftCollectionId = await createCollectionExpectSuccess();42 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');4344 // explicitely set transfer flag45 await setTransferFlagExpectSuccess(Alice, nftCollectionId, false);4647 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);48 });49 });50});tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -523,6 +523,18 @@
});
}
+export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {
+
+ await usingApi(async (api) => {
+
+ const tx = api.tx.nft.setTransfersEnabledFlag (collectionId, enabled);
+ const events = await submitTransactionAsync(sender, tx);
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.true;
+ });
+}
+
export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {
await usingApi(async (api) => {
const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);