git.delta.rocks / unique-network / refs/commits / 878b12ba6816

difftreelog

Tests: eth tokenProperties small improvements

Maksandre2022-10-05parent: #3505807.patch.diff
in: master

1 file changed

modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
1import {IKeyringPair} from '@polkadot/types/types';
1import {cartesian} from './util/helpers';2import {usingPlaygrounds} from './../util/playgrounds/index';
2import {itEth, expect} from '../eth/util/playgrounds';3import {itEth, expect} from '../eth/util/playgrounds';
34
4describe('EVM token properties', () => {5describe('EVM token properties', () => {
6 let donor: IKeyringPair;
7 let alice: IKeyringPair;
8
9 before(async () => {
10 await usingPlaygrounds(async (helper, privateKey) => {
11 donor = privateKey('//Alice');
12 [alice] = await helper.arrange.createAccounts([1000n], donor);
13 });
14 });
15
5 itEth('Can be reconfigured', async({helper, privateKey}) => {16 itEth('Can be reconfigured', async({helper}) => {
6 const alice = privateKey('//Alice');
7 const caller = await helper.eth.createAccountWithBalance(alice);17 const caller = await helper.eth.createAccountWithBalance(donor);
818
9 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {19 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
10 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'ethp'});20 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'ethp'});
23 }33 }
24 });34 });
2535
26 itEth('Can be set', async({helper, privateKey}) => {36 itEth('Can be set', async({helper}) => {
27 const alice = privateKey('//Alice');
28 const caller = await helper.eth.createAccountWithBalance(alice);37 const caller = await helper.eth.createAccountWithBalance(donor);
29 const collection = await helper.nft.mintCollection(alice, {38 const collection = await helper.nft.mintCollection(alice, {
30 tokenPrefix: 'ethp',39 tokenPrefix: 'ethp',
31 tokenPropertyPermissions: [{40 tokenPropertyPermissions: [{
48 expect(value).to.equal('testValue');57 expect(value).to.equal('testValue');
49 });58 });
5059
51 itEth('Can be deleted', async({helper, privateKey}) => {60 itEth('Can be deleted', async({helper}) => {
52 const alice = privateKey('//Alice');
53 const caller = await helper.eth.createAccountWithBalance(alice);61 const caller = await helper.eth.createAccountWithBalance(donor);
54 const collection = await helper.nft.mintCollection(alice, {62 const collection = await helper.nft.mintCollection(alice, {
55 tokenPrefix: 'ethp',63 tokenPrefix: 'ethp',
56 tokenPropertyPermissions: [{64 tokenPropertyPermissions: [{
76 expect(result.length).to.equal(0);84 expect(result.length).to.equal(0);
77 });85 });
7886
79 itEth('Can be read', async({helper, privateKey}) => {87 itEth('Can be read', async({helper}) => {
80 const alice = privateKey('//Alice');
81 const caller = await helper.eth.createAccountWithBalance(alice);88 const caller = await helper.eth.createAccountWithBalance(donor);
82 const collection = await helper.nft.mintCollection(alice, {89 const collection = await helper.nft.mintCollection(alice, {
83 tokenPrefix: 'ethp',90 tokenPrefix: 'ethp',
84 tokenPropertyPermissions: [{91 tokenPropertyPermissions: [{
100});107});
101108
109
110type ElementOf<A> = A extends readonly (infer T)[] ? T : never;
111function* cartesian<T extends Array<Array<any>>, R extends Array<any>>(internalRest: [...R], ...args: [...T]): Generator<[...R, ...{[K in keyof T]: ElementOf<T[K]>}]> {
112 if(args.length === 0) {
113 yield internalRest as any;
114 return;
115 }
116 for(const value of args[0]) {
117 yield* cartesian([...internalRest, value], ...args.slice(1)) as any;
118 }
119}