From 44f9d3c6ebe42965fa1d088356e62e6b7158ef4c Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Mon, 25 Jan 2021 13:08:29 +0000 Subject: [PATCH] tests: find not existing ids --- --- a/tests/src/setVariableMetaData.test.ts +++ b/tests/src/setVariableMetaData.test.ts @@ -8,6 +8,7 @@ createCollectionExpectSuccess, createItemExpectSuccess, destroyCollectionExpectSuccess, + findNotExistingCollection, setVariableMetaDataExpectFailure, setVariableMetaDataExpectSuccess, } from './util/helpers'; @@ -62,9 +63,10 @@ }); it('fails on not existing collection id', async () => { - // Not sure how to implement it - const nonExistingCollectionId = 200000; - await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data); + await usingApi(async api => { + let nonExistingCollectionId = await findNotExistingCollection(api); + await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data); + }); }); it('fails on removed collection id', async () => { const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } }); @@ -81,7 +83,7 @@ await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data); }); it('fails on not existing token', async () => { - const nonExistingTokenId = 200000; + const nonExistingTokenId = validTokenId + 1; await setVariableMetaDataExpectFailure(alice, validCollectionId, nonExistingTokenId, data); }); --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -253,6 +253,11 @@ return unused; } +export async function findNotExistingCollection(api: ApiPromise): Promise { + let collection: number = parseInt((await api.query.nft.createdCollectionCount()).toString()) as unknown as number + 1; + return collection; +} + function getDestroyResult(events: EventRecord[]): boolean { let success: boolean = false; events.forEach(({ phase, event: { data, method, section } }) => { -- gitstuff