difftreelog
CORE-36. Integration tests
in: master
2 files changed
tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/enableDisableTransfer.test.ts
@@ -0,0 +1,50 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from './substrate/privateKey';
+import usingApi from './substrate/substrate-api';
+import {
+ createItemExpectSuccess,
+ createCollectionExpectSuccess,
+ transferExpectSuccess,
+ transferExpectFailure,
+ setTransferFlagExpectSuccess
+} from './util/helpers';
+
+chai.use(chaiAsPromised);
+
+describe('Enable/Disable Transfers', () => {
+ it.only('User can transfer token with enabled transfer flag', async () => {
+ await usingApi(async () => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ // nft
+ const nftCollectionId = await createCollectionExpectSuccess();
+ const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+
+ // explicitely set transfer flag
+ await setTransferFlagExpectSuccess(Alice, nftCollectionId, true);
+
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ });
+ });
+
+ it.only('User can\'n transfer token with disabled transfer flag', async () => {
+ await usingApi(async () => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ // nft
+ const nftCollectionId = await createCollectionExpectSuccess();
+ const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+
+ // explicitely set transfer flag
+ await setTransferFlagExpectSuccess(Alice, nftCollectionId, false);
+
+ await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ });
+ });
+});
tests/src/util/helpers.tsdiffbeforeafterboth523 });523 });524}524}525526export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {527528 await usingApi(async (api) => {529530 const tx = api.tx.nft.setTransfersEnabledFlag (collectionId, enabled);531 const events = await submitTransactionAsync(sender, tx);532 const result = getGenericResult(events);533534 expect(result.success).to.be.true;535 }); 536}525537526export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {538export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {527 await usingApi(async (api) => {539 await usingApi(async (api) => {