difftreelog
test(common-migration) collection fields remain the same
in: master
2 files changed
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -34,6 +34,7 @@
"testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
"testEvent": "mocha --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",
"testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",
+ "testMigrationStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",
"testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",
"testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",
"testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts",
tests/src/nesting/migration-check.test.tsdiffbeforeafterboth1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';4import {getCreateCollectionResult} from '../util/helpers';5import {IKeyringPair} from '@polkadot/types/types';6import {strToUTF16} from '../util/util';7import waitNewBlocks from '../substrate/wait-new-blocks';89// todo skip10describe.skip('Migration testing for pallet-common', () => {11 let alice: IKeyringPair;12 13 before(async() => {14 await usingApi(async api => {15 alice = privateKey('//Alice');16 });17 });1819 it('Preserves collection settings', async () => {20 let old_version: number;21 let collection_id: number;22 let collection_old: any;2324 await usingApi(async api => {25 // Create a collection for comparison before and after the upgrade26 const tx = api.tx.unique.createCollectionEx({27 mode: 'NFT',28 access: 'AllowList',29 name: strToUTF16("Mojave Pictures"),30 description: strToUTF16("$2.2 billion power plant!"),31 tokenPrefix: '0x0002030',32 offchainSchema: '0x111111',33 schemaVersion: 'Unique',34 limits: {35 accountTokenOwnershipLimit: 3,36 },37 variableOnChainSchema: '0x222222',38 constOnChainSchema: '0x333333',39 metaUpdatePermission: 'Admin',40 });41 const events = await submitTransactionAsync(alice, tx);42 const result = getCreateCollectionResult(events);43 collection_id = result.collectionId;4445 // Get the pre-upgrade collection info46 collection_old = (await api.query.common.collectionById(collection_id)).toJSON();4748 // Get the pre-upgrade spec version49 old_version = (api.consts.system.version.toJSON() as any).specVersion;50 });5152 console.log(`Now waiting for the parachain upgrade from ${old_version!}...`);5354 let new_version = old_version!;55 let connection_fail_counter = 0;5657 // And wait for the parachain upgrade58 while (new_version == old_version! && connection_fail_counter < 2) {59 try {60 await usingApi(async api => {61 await waitNewBlocks(api);62 new_version = (api.consts.system.version.toJSON() as any).specVersion;63 });64 } catch (_) {65 connection_fail_counter++;66 await new Promise( resolve => setTimeout(resolve, 12000) );67 }68 }6970 await usingApi(async api => {71 const collection_new = (await api.query.common.collectionById(collection_id)).toJSON() as any;72 73 // Make sure the extra fields are what they should be74 const variable_on_chain_schema = await api.query.common.collectionData(collection_id, "VariableOnChainSchema");75 const const_on_chain_schema = await api.query.common.collectionData(collection_id, "ConstOnChainSchema");76 const offchain_schema = await api.query.common.collectionData(collection_id, "OffchainSchema");7778 expect(variable_on_chain_schema.toHex()).to.be.deep.equal((collection_old.variableOnChainSchema));79 expect(const_on_chain_schema.toHex()).to.be.deep.equal(collection_old.constOnChainSchema);80 expect(offchain_schema.toHex()).to.be.deep.equal(collection_old.offchainSchema);81 expect(collection_new).to.have.nested.property('limits.nestingRule');8283 // Get rid of extra fields to perform comparison on the rest of the collection84 delete collection_new.limits.nestingRule;85 delete collection_old.constOnChainSchema;86 delete collection_old.offchainSchema;87 delete collection_old.variableOnChainSchema;8889 expect(collection_new).to.be.deep.equal(collection_old);90 });91 });92});93