difftreelog
CORE-410 Restor tests
in: master
6 files changed
tests/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]>;
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -2461,12 +2461,14 @@
export interface UpDataStructsCreateReFungibleData extends Struct {
readonly constData: Bytes;
readonly pieces: u128;
+ readonly properties: Vec<UpDataStructsProperty>;
}
/** @name UpDataStructsCreateRefungibleExData */
export interface UpDataStructsCreateRefungibleExData extends Struct {
readonly constData: Bytes;
readonly users: BTreeMap<PalletEvmAccountBasicCrossAccountIdRepr, u128>;
+ readonly properties: Vec<UpDataStructsProperty>;
}
/** @name UpDataStructsNestingPermissions */
tests/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>
tests/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) */
tests/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', () => {
tests/src/util/helpers.tsdiffbeforeafterboth1414 tx = api.tx.unique.createItem(collectionId, to, createData as any);1414 tx = api.tx.unique.createItem(collectionId, to, createData as any);1415 }1415 }141614161417 const events = await submitTransactionAsync(sender, tx);1417 const events = await executeTransaction(api, sender, tx);1418 const result = getCreateItemResult(events);1418 const result = getCreateItemResult(events);141914191420 const itemCountAfter = await getLastTokenId(api, collectionId);1420 const itemCountAfter = await getLastTokenId(api, collectionId);