From 878b12ba681617e27802aec47c77ad39eabfa659 Mon Sep 17 00:00:00 2001 From: Maksandre Date: Wed, 05 Oct 2022 12:07:30 +0000 Subject: [PATCH] Tests: eth tokenProperties small improvements --- --- a/tests/src/eth/tokenProperties.test.ts +++ b/tests/src/eth/tokenProperties.test.ts @@ -1,11 +1,21 @@ -import {cartesian} from './util/helpers'; +import {IKeyringPair} from '@polkadot/types/types'; +import {usingPlaygrounds} from './../util/playgrounds/index'; import {itEth, expect} from '../eth/util/playgrounds'; describe('EVM token properties', () => { - itEth('Can be reconfigured', async({helper, privateKey}) => { - const alice = privateKey('//Alice'); - const caller = await helper.eth.createAccountWithBalance(alice); + let donor: IKeyringPair; + let alice: IKeyringPair; + before(async () => { + await usingPlaygrounds(async (helper, privateKey) => { + donor = privateKey('//Alice'); + [alice] = await helper.arrange.createAccounts([1000n], donor); + }); + }); + + itEth('Can be reconfigured', async({helper}) => { + const caller = await helper.eth.createAccountWithBalance(donor); + for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) { const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'ethp'}); await collection.addAdmin(alice, {Ethereum: caller}); @@ -23,9 +33,8 @@ } }); - itEth('Can be set', async({helper, privateKey}) => { - const alice = privateKey('//Alice'); - const caller = await helper.eth.createAccountWithBalance(alice); + itEth('Can be set', async({helper}) => { + const caller = await helper.eth.createAccountWithBalance(donor); const collection = await helper.nft.mintCollection(alice, { tokenPrefix: 'ethp', tokenPropertyPermissions: [{ @@ -48,9 +57,8 @@ expect(value).to.equal('testValue'); }); - itEth('Can be deleted', async({helper, privateKey}) => { - const alice = privateKey('//Alice'); - const caller = await helper.eth.createAccountWithBalance(alice); + itEth('Can be deleted', async({helper}) => { + const caller = await helper.eth.createAccountWithBalance(donor); const collection = await helper.nft.mintCollection(alice, { tokenPrefix: 'ethp', tokenPropertyPermissions: [{ @@ -76,9 +84,8 @@ expect(result.length).to.equal(0); }); - itEth('Can be read', async({helper, privateKey}) => { - const alice = privateKey('//Alice'); - const caller = await helper.eth.createAccountWithBalance(alice); + itEth('Can be read', async({helper}) => { + const caller = await helper.eth.createAccountWithBalance(donor); const collection = await helper.nft.mintCollection(alice, { tokenPrefix: 'ethp', tokenPropertyPermissions: [{ @@ -98,3 +105,15 @@ expect(value).to.equal(helper.getWeb3().utils.toHex('testValue')); }); }); + + +type ElementOf = A extends readonly (infer T)[] ? T : never; +function* cartesian>, R extends Array>(internalRest: [...R], ...args: [...T]): Generator<[...R, ...{[K in keyof T]: ElementOf}]> { + if(args.length === 0) { + yield internalRest as any; + return; + } + for(const value of args[0]) { + yield* cartesian([...internalRest, value], ...args.slice(1)) as any; + } +} \ No newline at end of file -- gitstuff