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
408 **/408 **/
409 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]>;409 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]>;
410 tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<PalletRefungibleItemData>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;410 tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<PalletRefungibleItemData>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
411 tokenProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<UpDataStructsProperties>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
411 tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;412 tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
412 tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;413 tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
413 totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;414 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
1502 **/1502 **/
1503 UpDataStructsCreateReFungibleData: {1503 UpDataStructsCreateReFungibleData: {
1504 constData: 'Bytes',1504 constData: 'Bytes',
1505 pieces: 'u128'1505 pieces: 'u128',
1506 properties: 'Vec<UpDataStructsProperty>'
1506 },1507 },
1507 /**1508 /**
1508 * Lookup193: up_data_structs::CreateItemExData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>1509 * Lookup193: up_data_structs::CreateItemExData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
1527 **/1528 **/
1528 UpDataStructsCreateRefungibleExData: {1529 UpDataStructsCreateRefungibleExData: {
1529 constData: 'Bytes',1530 constData: 'Bytes',
1530 users: 'BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>'1531 users: 'BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>',
1532 properties: 'Vec<UpDataStructsProperty>'
1531 },1533 },
1532 /**1534 /**
1533 * Lookup204: pallet_unique_scheduler::pallet::Call<T>1535 * Lookup204: pallet_unique_scheduler::pallet::Call<T>
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
1629 export interface UpDataStructsCreateReFungibleData extends Struct {1629 export interface UpDataStructsCreateReFungibleData extends Struct {
1630 readonly constData: Bytes;1630 readonly constData: Bytes;
1631 readonly pieces: u128;1631 readonly pieces: u128;
1632 readonly properties: Vec<UpDataStructsProperty>;
1632 }1633 }
16331634
1634 /** @name UpDataStructsCreateItemExData (193) */1635 /** @name UpDataStructsCreateItemExData (193) */
1654 export interface UpDataStructsCreateRefungibleExData extends Struct {1655 export interface UpDataStructsCreateRefungibleExData extends Struct {
1655 readonly constData: Bytes;1656 readonly constData: Bytes;
1656 readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;1657 readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;
1658 readonly properties: Vec<UpDataStructsProperty>;
1657 }1659 }
16581660
1659 /** @name PalletUniqueSchedulerCall (204) */1661 /** @name PalletUniqueSchedulerCall (204) */
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
806 await testDeletePropertiesAccordingPermission({type: 'ReFungible'}, 100);806 await testDeletePropertiesAccordingPermission({type: 'ReFungible'}, 100);
807 });807 });
808808
809 // it('Assigns properties to a nested token according to permissions', async () => {809 it('Assigns properties to a nested token according to permissions', async () => {
810 // await usingApi(async api => {810 await usingApi(async api => {
811 // const propertyKeys: string[] = [];811 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
812 // let i = 0;812 await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
813 // for (const permission of permissions) {813 const token = await createItemExpectSuccess(alice, collection, 'NFT');
814 // for (const signer of permission.signers) {814 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
815 // const key = i + '_' + signer.address;815 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
816 // propertyKeys.push(key);816 await transferExpectSuccess(collection, token, alice, charlie);
817817
818 // await expect(executeTransaction(818 const propertyKeys: string[] = [];
819 // api, 819 let i = 0;
820 // alice, 820 for (const permission of permissions) {
821 // api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 821 for (const signer of permission.signers) {
822 // ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;822 const key = i + '_' + signer.address;
823823 propertyKeys.push(key);
824 // await expect(executeTransaction(824
825 // api, 825 await expect(executeTransaction(
826 // signer, 826 api,
827 // api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 827 alice,
828 // ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;828 api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
829 // }829 ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
830830
831 // i++;831 await expect(executeTransaction(
832 // }832 api,
833833 signer,
834 // const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];834 api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]),
835 // const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];835 ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
836 // for (let i = 0; i < properties.length; i++) {836 }
837 // expect(properties[i].value).to.be.equal('Serotonin increase');837
838 // expect(tokensData[i].value).to.be.equal('Serotonin increase');838 i++;
839 // }839 }
840 // });840
841 // });841 const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
842842 const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
843 // it('Changes properties of a nested token according to permissions', async () => {843 for (let i = 0; i < properties.length; i++) {
844 // await usingApi(async api => {844 expect(properties[i].value).to.be.equal('Serotonin increase');
845 // const propertyKeys: string[] = [];845 expect(tokensData[i].value).to.be.equal('Serotonin increase');
846 // let i = 0;846 }
847 // for (const permission of permissions) {847 });
848 // if (!permission.permission.mutable) continue;848 });
849 849
850 // for (const signer of permission.signers) {850 it('Changes properties of a nested token according to permissions', async () => {
851 // const key = i + '_' + signer.address;851 await usingApi(async api => {
852 // propertyKeys.push(key);852 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
853853 await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
854 // await expect(executeTransaction(854 const token = await createItemExpectSuccess(alice, collection, 'NFT');
855 // api, 855 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
856 // alice, 856 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
857 // api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 857 await transferExpectSuccess(collection, token, alice, charlie);
858 // ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;858
859859 const propertyKeys: string[] = [];
860 // await expect(executeTransaction(860 let i = 0;
861 // api, 861 for (const permission of permissions) {
862 // signer, 862 if (!permission.permission.mutable) continue;
863 // api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 863
864 // ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;864 for (const signer of permission.signers) {
865865 const key = i + '_' + signer.address;
866 // await expect(executeTransaction(866 propertyKeys.push(key);
867 // api, 867
868 // signer, 868 await expect(executeTransaction(
869 // api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin stable'}]), 869 api,
870 // ), `on changing property ${i} by ${signer.address}`).to.not.be.rejected;870 alice,
871 // }871 api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
872872 ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
873 // i++;873
874 // }874 await expect(executeTransaction(
875875 api,
876 // const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];876 signer,
877 // const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];877 api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]),
878 // for (let i = 0; i < properties.length; i++) {878 ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
879 // expect(properties[i].value).to.be.equal('Serotonin stable');879
880 // expect(tokensData[i].value).to.be.equal('Serotonin stable');880 await expect(executeTransaction(
881 // }881 api,
882 // });882 signer,
883 // });883 api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin stable'}]),
884884 ), `on changing property ${i} by ${signer.address}`).to.not.be.rejected;
885 // it('Deletes properties of a nested token according to permissions', async () => {885 }
886 // await usingApi(async api => {886
887 // const propertyKeys: string[] = [];887 i++;
888 // let i = 0;888 }
889889
890 // for (const permission of permissions) {890 const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toHuman() as any[];
891 // if (!permission.permission.mutable) continue;891 const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toHuman().properties as any[];
892 892 for (let i = 0; i < properties.length; i++) {
893 // for (const signer of permission.signers) {893 expect(properties[i].value).to.be.equal('Serotonin stable');
894 // const key = i + '_' + signer.address;894 expect(tokensData[i].value).to.be.equal('Serotonin stable');
895 // propertyKeys.push(key);895 }
896896 });
897 // await expect(executeTransaction(897 });
898 // api, 898
899 // alice, 899 it('Deletes properties of a nested token according to permissions', async () => {
900 // api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]), 900 await usingApi(async api => {
901 // ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;901 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
902902 await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {tokenOwner: true}});
903 // await expect(executeTransaction(903 const token = await createItemExpectSuccess(alice, collection, 'NFT');
904 // api, 904 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, token)});
905 // signer, 905 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
906 // api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]), 906 await transferExpectSuccess(collection, token, alice, charlie);
907 // ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;907
908908 const propertyKeys: string[] = [];
909 // await expect(executeTransaction(909 let i = 0;
910 // api, 910
911 // signer, 911 for (const permission of permissions) {
912 // api.tx.unique.deleteTokenProperties(collection, nestedToken, [key]), 912 if (!permission.permission.mutable) continue;
913 // ), `on deleting property ${i} by ${signer.address}`).to.not.be.rejected;913
914 // }914 for (const signer of permission.signers) {
915 915 const key = i + '_' + signer.address;
916 // i++;916 propertyKeys.push(key);
917 // }917
918918 await expect(executeTransaction(
919 // const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toJSON() as any[];919 api,
920 // expect(properties).to.be.empty;920 alice,
921 // const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toJSON().properties as any[];921 api.tx.unique.setTokenPropertyPermissions(collection, [{key: key, permission: permission.permission}]),
922 // expect(tokensData).to.be.empty;922 ), `on setting permission ${i} by ${signer.address}`).to.not.be.rejected;
923 // expect((await api.query.nonfungible.tokenProperties(collection, nestedToken)).toJSON().consumedSpace).to.be.equal(0);923
924 // });924 await expect(executeTransaction(
925 // });925 api,
926 signer,
927 api.tx.unique.setTokenProperties(collection, nestedToken, [{key: key, value: 'Serotonin increase'}]),
928 ), `on adding property ${i} by ${signer.address}`).to.not.be.rejected;
929
930 await expect(executeTransaction(
931 api,
932 signer,
933 api.tx.unique.deleteTokenProperties(collection, nestedToken, [key]),
934 ), `on deleting property ${i} by ${signer.address}`).to.not.be.rejected;
935 }
936
937 i++;
938 }
939
940 const properties = (await api.rpc.unique.tokenProperties(collection, nestedToken, propertyKeys)).toJSON() as any[];
941 expect(properties).to.be.empty;
942 const tokensData = (await api.rpc.unique.tokenData(collection, nestedToken, propertyKeys)).toJSON().properties as any[];
943 expect(tokensData).to.be.empty;
944 expect((await api.query.nonfungible.tokenProperties(collection, nestedToken)).toJSON().consumedSpace).to.be.equal(0);
945 });
946 });
926});947});
927948
928describe('Negative Integration Test: Token Properties', () => {949describe('Negative Integration Test: Token Properties', () => {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1414 tx = api.tx.unique.createItem(collectionId, to, createData as any);1414 tx = api.tx.unique.createItem(collectionId, to, createData as any);
1415 }1415 }
14161416
1417 const events = await submitTransactionAsync(sender, tx);1417 const events = await executeTransaction(api, sender, tx);
1418 const result = getCreateItemResult(events);1418 const result = getCreateItemResult(events);
14191419
1420 const itemCountAfter = await getLastTokenId(api, collectionId);1420 const itemCountAfter = await getLastTokenId(api, collectionId);