difftreelog
Update transfer disable tests
in: master
3 files changed
tests/package.jsondiffbeforeafterboth59 "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts",59 "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts",60 "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",60 "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",61 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",61 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",62 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts"62 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",63 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts"63 },64 },64 "author": "",65 "author": "",65 "license": "SEE LICENSE IN ../LICENSE",66 "license": "SEE LICENSE IN ../LICENSE",tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth--- a/tests/src/enableDisableTransfer.test.ts
+++ b/tests/src/enableDisableTransfer.test.ts
@@ -13,6 +13,7 @@
transferExpectSuccess,
transferExpectFailure,
setTransferFlagExpectSuccess,
+ setTransferFlagExpectFailure,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -48,3 +49,16 @@
});
});
});
+
+describe('Negative Enable/Disable Transfers', () => {
+ it('Non-owner cannot change transfer flag', async () => {
+ await usingApi(async () => {
+ const Bob = privateKey('//Bob');
+ // nft
+ const nftCollectionId = await createCollectionExpectSuccess();
+
+ // Change transfer flag
+ await setTransferFlagExpectFailure(Bob, nftCollectionId, false);
+ });
+ });
+});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -535,6 +535,18 @@
});
}
+export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {
+
+ await usingApi(async (api) => {
+
+ const tx = api.tx.nft.setTransfersEnabledFlag (collectionId, enabled);
+ const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.false;
+ });
+}
+
export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {
await usingApi(async (api) => {
const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);