git.delta.rocks / unique-network / refs/commits / c7ac40c1ba37

difftreelog

CORE-410 Restor tests

Trubnikov Sergey2022-07-08parent: #3cb5e43.patch.diff
in: master

6 files changed

modifiedtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -408,6 +408,7 @@
        **/
       owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, u32]>;
       tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<PalletRefungibleItemData>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+      tokenProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<UpDataStructsProperties>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
       tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
       tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
       totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
2461export interface UpDataStructsCreateReFungibleData extends Struct {2461export interface UpDataStructsCreateReFungibleData extends Struct {
2462 readonly constData: Bytes;2462 readonly constData: Bytes;
2463 readonly pieces: u128;2463 readonly pieces: u128;
2464 readonly properties: Vec<UpDataStructsProperty>;
2464}2465}
24652466
2466/** @name UpDataStructsCreateRefungibleExData */2467/** @name UpDataStructsCreateRefungibleExData */
2467export interface UpDataStructsCreateRefungibleExData extends Struct {2468export interface UpDataStructsCreateRefungibleExData extends Struct {
2468 readonly constData: Bytes;2469 readonly constData: Bytes;
2469 readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;2470 readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;
2471 readonly properties: Vec<UpDataStructsProperty>;
2470}2472}
24712473
2472/** @name UpDataStructsNestingPermissions */2474/** @name UpDataStructsNestingPermissions */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1502,7 +1502,8 @@
    **/
   UpDataStructsCreateReFungibleData: {
     constData: 'Bytes',
-    pieces: 'u128'
+    pieces: 'u128',
+    properties: 'Vec<UpDataStructsProperty>'
   },
   /**
    * Lookup193: up_data_structs::CreateItemExData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
@@ -1527,7 +1528,8 @@
    **/
   UpDataStructsCreateRefungibleExData: {
     constData: 'Bytes',
-    users: 'BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>'
+    users: 'BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>',
+    properties: 'Vec<UpDataStructsProperty>'
   },
   /**
    * Lookup204: pallet_unique_scheduler::pallet::Call<T>
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1629,6 +1629,7 @@
   export interface UpDataStructsCreateReFungibleData extends Struct {
     readonly constData: Bytes;
     readonly pieces: u128;
+    readonly properties: Vec<UpDataStructsProperty>;
   }
 
   /** @name UpDataStructsCreateItemExData (193) */
@@ -1654,6 +1655,7 @@
   export interface UpDataStructsCreateRefungibleExData extends Struct {
     readonly constData: Bytes;
     readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;
+    readonly properties: Vec<UpDataStructsProperty>;
   }
 
   /** @name PalletUniqueSchedulerCall (204) */
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -806,123 +806,144 @@
     await testDeletePropertiesAccordingPermission({type: 'ReFungible'}, 100);
   });
 
-  // it('Assigns properties to a nested token according to permissions', async () => {
-  //   await usingApi(async api => {
-  //     const propertyKeys: string[] = [];
-  //     let i = 0;
-  //     for (const permission of permissions) {
-  //       for (const signer of permission.signers) {
-  //         const key = i + '_' + signer.address;
-  //         propertyKeys.push(key);
+  it('Assigns properties to a nested token according to permissions', async () => {
+    await usingApi(async api => {
+      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+      await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
+      const token = await createItemExpectSuccess(alice, collection, 'NFT');
+      const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
+      await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+      await transferExpectSuccess(collection, token, alice, charlie);
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           alice, 
-  //           api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
-  //         ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
+      const propertyKeys: string[] = [];
+      let i = 0;
+      for (const permission of permissions) {
+        for (const signer of permission.signers) {
+          const key = i + '_' + signer.address;
+          propertyKeys.push(key);
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           signer, 
-  //           api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
-  //         ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
-  //       }
+          await expect(executeTransaction(
+            api, 
+            alice, 
+            api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
+          ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
 
-  //       i++;
-  //     }
+          await expect(executeTransaction(
+            api, 
+            signer, 
+            api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
+          ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
+        }
 
-  //     const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
-  //     const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
-  //     for (let i = 0; i < properties.length; i++) {
-  //       expect(properties[i].value).to.be.equal('Serotonin increase');
-  //       expect(tokensData[i].value).to.be.equal('Serotonin increase');
-  //     }
-  //   });
-  // });
+        i++;
+      }
+
+      const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
+      const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
+      for (let i = 0; i < properties.length; i++) {
+        expect(properties[i].value).to.be.equal('Serotonin increase');
+        expect(tokensData[i].value).to.be.equal('Serotonin increase');
+      }
+    });
+  });
 
-  // it('Changes properties of a nested token according to permissions', async () => {
-  //   await usingApi(async api => {
-  //     const propertyKeys: string[] = [];
-  //     let i = 0;
-  //     for (const permission of permissions) {
-  //       if (!permission.permission.mutable) continue;
+  it('Changes properties of a nested token according to permissions', async () => {
+    await usingApi(async api => {
+      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+      await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
+      const token = await createItemExpectSuccess(alice, collection, 'NFT');
+      const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
+      await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+      await transferExpectSuccess(collection, token, alice, charlie);
+
+      const propertyKeys: string[] = [];
+      let i = 0;
+      for (const permission of permissions) {
+        if (!permission.permission.mutable) continue;
         
-  //       for (const signer of permission.signers) {
-  //         const key = i + '_' + signer.address;
-  //         propertyKeys.push(key);
+        for (const signer of permission.signers) {
+          const key = i + '_' + signer.address;
+          propertyKeys.push(key);
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           alice, 
-  //           api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
-  //         ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
+          await expect(executeTransaction(
+            api, 
+            alice, 
+            api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
+          ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           signer, 
-  //           api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
-  //         ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
+          await expect(executeTransaction(
+            api, 
+            signer, 
+            api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
+          ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           signer, 
-  //           api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin stable'}]), 
-  //         ), `on changing property ${i} by ${signer.address}`).to.not.be.rejected;
-  //       }
+          await expect(executeTransaction(
+            api, 
+            signer, 
+            api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin stable'}]), 
+          ), `on changing property ${i} by ${signer.address}`).to.not.be.rejected;
+        }
 
-  //       i++;
-  //     }
+        i++;
+      }
 
-  //     const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
-  //     const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
-  //     for (let i = 0; i < properties.length; i++) {
-  //       expect(properties[i].value).to.be.equal('Serotonin stable');
-  //       expect(tokensData[i].value).to.be.equal('Serotonin stable');
-  //     }
-  //   });
-  // });
+      const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
+      const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
+      for (let i = 0; i < properties.length; i++) {
+        expect(properties[i].value).to.be.equal('Serotonin stable');
+        expect(tokensData[i].value).to.be.equal('Serotonin stable');
+      }
+    });
+  });
+
+  it('Deletes properties of a nested token according to permissions', async () => {
+    await usingApi(async api => {
+      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+      await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
+      const token = await createItemExpectSuccess(alice, collection, 'NFT');
+      const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
+      await addCollectionAdminExpectSuccess(alice, collection, bob.address);
+      await transferExpectSuccess(collection, token, alice, charlie);
 
-  // it('Deletes properties of a nested token according to permissions', async () => {
-  //   await usingApi(async api => {
-  //     const propertyKeys: string[] = [];
-  //     let i = 0;
+      const propertyKeys: string[] = [];
+      let i = 0;
 
-  //     for (const permission of permissions) {
-  //       if (!permission.permission.mutable) continue;
+      for (const permission of permissions) {
+        if (!permission.permission.mutable) continue;
         
-  //       for (const signer of permission.signers) {
-  //         const key = i + '_' + signer.address;
-  //         propertyKeys.push(key);
+        for (const signer of permission.signers) {
+          const key = i + '_' + signer.address;
+          propertyKeys.push(key);
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           alice, 
-  //           api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
-  //         ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
+          await expect(executeTransaction(
+            api, 
+            alice, 
+            api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 
+          ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           signer, 
-  //           api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
-  //         ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
+          await expect(executeTransaction(
+            api, 
+            signer, 
+            api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 
+          ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
 
-  //         await expect(executeTransaction(
-  //           api, 
-  //           signer, 
-  //           api.tx.unique.deleteTokenProperties(collection, nestedToken, [key]), 
-  //         ), `on deleting property ${i} by ${signer.address}`).to.not.be.rejected;
-  //       }
+          await expect(executeTransaction(
+            api, 
+            signer, 
+            api.tx.unique.deleteTokenProperties(collection, nestedToken, [key]), 
+          ), `on deleting property ${i} by ${signer.address}`).to.not.be.rejected;
+        }
         
-  //       i++;
-  //     }
+        i++;
+      }
 
-  //     const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toJSON() as any[];
-  //     expect(properties).to.be.empty;
-  //     const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toJSON().properties as any[];
-  //     expect(tokensData).to.be.empty;
-  //     expect((await api.query.nonfungible.tokenProperties(collection, nestedToken)).toJSON().consumedSpace).to.be.equal(0);
-  //   });
-  // });
+      const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toJSON() as any[];
+      expect(properties).to.be.empty;
+      const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toJSON().properties as any[];
+      expect(tokensData).to.be.empty;
+      expect((await api.query.nonfungible.tokenProperties(collection, nestedToken)).toJSON().consumedSpace).to.be.equal(0);
+    });
+  });
 });
 
 describe('Negative Integration Test: Token Properties', () => {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -1414,7 +1414,7 @@
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     }
 
-    const events = await submitTransactionAsync(sender, tx);
+    const events = await executeTransaction(api, sender, tx);
     const result = getCreateItemResult(events);
 
     const itemCountAfter = await getLastTokenId(api, collectionId);