--- a/tests/package.json +++ b/tests/package.json @@ -59,7 +59,8 @@ "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts", "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts", "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts", - "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts" + "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts", + "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts" }, "author": "", "license": "SEE LICENSE IN ../LICENSE", --- 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); + }); + }); +}); --- 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);