difftreelog
test migration from 921000 to 922000
in: master
2 files changed
tests/package.jsondiffbeforeafterboth37 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",37 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",38 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",38 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",39 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts",39 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts",40 "testMigrationStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",40 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",41 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",41 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",42 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",42 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",43 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",43 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",tests/src/nesting/migration-check.test.tsdiffbeforeafterboth--- a/tests/src/nesting/migration-check.test.ts
+++ b/tests/src/nesting/migration-check.test.ts
@@ -1,6 +1,6 @@
import {expect} from 'chai';
-import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import {getCreateCollectionResult} from '../util/helpers';
+import usingApi, {executeTransaction, submitTransactionAsync} from '../substrate/substrate-api';
+import {getCreateCollectionResult, getCreateItemResult, normalizeAccountId} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
import {strToUTF16} from '../util/util';
import waitNewBlocks from '../substrate/wait-new-blocks';
@@ -8,11 +8,11 @@
import find from 'find-process';
// todo un-skip for migrations
-describe.skip('Migration testing for pallet-common', () => {
+describe.skip('Migration testing', () => {
let alice: IKeyringPair;
before(async() => {
- await usingApi(async (api, privateKeyWrapper) => {
+ await usingApi(async (_, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
});
});
@@ -21,29 +21,51 @@
let oldVersion: number;
let collectionId: number;
let collectionOld: any;
+ let nftId: number;
+ let nftOld: any;
await usingApi(async api => {
- // Create a collection for comparison before and after the upgrade
- const tx = api.tx.unique.createCollectionEx({
+ // ----------- Collection pre-upgrade ------------
+ const txCollection = api.tx.unique.createCollectionEx({
mode: 'NFT',
access: 'AllowList',
name: strToUTF16('Mojave Pictures'),
description: strToUTF16('$2.2 billion power plant!'),
tokenPrefix: '0x0002030',
- //offchainSchema: '0x111111',
- //schemaVersion: 'Unique',
+ offchainSchema: '0x111111',
+ schemaVersion: 'Unique',
limits: {
accountTokenOwnershipLimit: 3,
},
- //constOnChainSchema: '0x333333',
+ constOnChainSchema: '0x333333',
+ variableOnChainSchema: '0x22222',
});
- const events = await submitTransactionAsync(alice, tx);
- const result = getCreateCollectionResult(events);
- collectionId = result.collectionId;
+ const events0 = await submitTransactionAsync(alice, txCollection);
+ const result0 = getCreateCollectionResult(events0);
+ collectionId = result0.collectionId;
// Get the pre-upgrade collection info
collectionOld = (await api.query.common.collectionById(collectionId)).toJSON();
+ // ---------- NFT pre-upgrade ------------
+ const txNft = api.tx.unique.createItem(
+ collectionId,
+ normalizeAccountId(alice),
+ {
+ NFT: {
+ owner: {substrate: alice.address},
+ constData: '0x0000',
+ variableData: '0x1111',
+ }
+ }
+ );
+ const events1 = await executeTransaction(api, alice, txNft);
+ const result1 = getCreateItemResult(events1);
+ nftId = result1.itemId;
+
+ // Get the pre-upgrade NFT data
+ nftOld = (await api.query.nonfungible.tokenData(collectionId, nftId)).toJSON();
+
// Get the pre-upgrade spec version
oldVersion = (api.consts.system.version.toJSON() as any).specVersion;
});
@@ -73,7 +95,8 @@
};
let oldWarnCount = 0;
- while (newVersion == oldVersion! && connectionFailCounter < 2) {
+ while (newVersion == oldVersion! && connectionFailCounter < 5) {
+ await new Promise(resolve => setTimeout(resolve, 12000));
try {
await usingApi(async api => {
await waitNewBlocks(api);
@@ -82,32 +105,69 @@
console.log(`Still waiting for the parachain upgrade from ${oldVersion!}...`);
oldWarnCount = warnCount;
}
- await new Promise(resolve => setTimeout(resolve, 6000));
});
} catch (_) {
connectionFailCounter++;
- await new Promise(resolve => setTimeout(resolve, 12000));
}
}
}
await usingApi(async api => {
+ // ---------- Collection comparison -----------
const collectionNew = (await api.query.common.collectionById(collectionId)).toJSON() as any;
// Make sure the extra fields are what they should be
- //const constOnChainSchema = await api.query.common.collectionData(collectionId, 'ConstOnChainSchema');
- //const offchainSchema = await api.query.common.collectionData(collectionId, 'OffchainSchema');
+ expect((await api.rpc.unique.collectionProperties(
+ collectionId, ['_old_constOnChainSchema']))[0].value.toHex()
+ ).to.be.equal(collectionOld.constOnChainSchema);
+
+ expect((await api.rpc.unique.collectionProperties(
+ collectionId, ['_old_variableOnChainSchema']))[0].value.toHex()
+ ).to.be.equal(collectionOld.variableOnChainSchema);
- //expect(constOnChainSchema.toHex()).to.be.deep.equal(collectionOld.constOnChainSchema);
- //expect(offchainSchema.toHex()).to.be.deep.equal(collectionOld.offchainSchema);
- expect(collectionNew).to.have.nested.property('limits.nestingRule');
+ expect((await api.rpc.unique.collectionProperties(
+ collectionId, ['_old_offchainSchema']))[0].value.toHex()
+ ).to.be.equal(collectionOld.offchainSchema);
+ expect((await api.rpc.unique.collectionProperties(
+ collectionId, ['_old_schemaVersion']))[0].value.toHuman()
+ ).to.be.equal(collectionOld.schemaVersion);
+
+ expect(collectionNew.permissions).to.be.deep.equal({
+ access: collectionOld.access,
+ mintMode: collectionOld.mintMode,
+ nesting: null,
+ });
+
// Get rid of extra fields to perform comparison on the rest of the collection
- delete collectionNew.limits.nestingRule;
- //delete collectionOld.constOnChainSchema;
- //delete collectionOld.offchainSchema;
+ delete collectionNew.permissions;
+ delete collectionOld.schemaVersion;
+ delete collectionOld.constOnChainSchema;
+ delete collectionOld.variableOnChainSchema;
+ delete collectionOld.offchainSchema;
+ delete collectionOld.mintMode;
+ delete collectionOld.access;
+ delete collectionOld.metaUpdatePermission; // todo look into, doesn't migrate
expect(collectionNew).to.be.deep.equal(collectionOld);
+
+ // ---------- NFT comparison -----------
+ const nftNew = (await api.query.nonfungible.tokenData(collectionId, nftId)).toJSON() as any;
+
+ // Make sure the extra fields are what they should be
+ expect((await api.rpc.unique.tokenProperties(
+ collectionId, nftId, ['_old_constData']))[0].value.toHex()
+ ).to.be.equal(nftOld.constData);
+
+ expect((await api.rpc.unique.tokenProperties(
+ collectionId, nftId, ['_old_variableData']))[0].value.toHex()
+ ).to.be.equal(nftOld.variableData);
+
+ // Get rid of extra fields to perform comparison on the rest of the NFT
+ delete nftOld.constData;
+ delete nftOld.variableData;
+
+ expect(nftNew).to.be.deep.equal(nftOld);
});
});
});