git.delta.rocks / unique-network / refs/commits / 07a6969a6bf5

difftreelog

test(common-migration) polkadot-launch signalling

Fahrrader2022-04-15parent: #5e6da29.patch.diff
in: master

3 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -84,6 +84,7 @@
     "@polkadot/util-crypto": "^9.1.1",
     "bignumber.js": "^9.0.2",
     "chai-as-promised": "^7.1.1",
+    "find-process": "^1.4.7",
     "solc": "^0.8.13",
     "web3": "^1.7.3"
   },
modifiedtests/src/nesting/migration-check.test.tsdiffbeforeafterboth
7import waitNewBlocks from '../substrate/wait-new-blocks';7import waitNewBlocks from '../substrate/wait-new-blocks';
88
9// todo skip9// todo skip
10describe.skip('Migration testing for pallet-common', () => {10describe('Migration testing for pallet-common', () => {
11 let alice: IKeyringPair;11 let alice: IKeyringPair;
12 12
13 before(async() => {13 before(async() => {
14 await usingApi(async api => {14 await usingApi(async () => {
15 alice = privateKey('//Alice');15 alice = privateKey('//Alice');
16 });16 });
17 });17 });
1818
19 it('Preserves collection settings', async () => {19 it('Preserves collection settings', async () => {
20 let old_version: number;20 let oldVersion: number;
21 let collection_id: number;21 let collectionId: number;
22 let collection_old: any;22 let collectionOld: any;
2323
24 await usingApi(async api => {24 await usingApi(async api => {
25 // Create a collection for comparison before and after the upgrade25 // Create a collection for comparison before and after the upgrade
26 const tx = api.tx.unique.createCollectionEx({26 const tx = api.tx.unique.createCollectionEx({
27 mode: 'NFT',27 mode: 'NFT',
28 access: 'AllowList',28 access: 'AllowList',
29 name: strToUTF16("Mojave Pictures"),29 name: strToUTF16('Mojave Pictures'),
30 description: strToUTF16("$2.2 billion power plant!"),30 description: strToUTF16('$2.2 billion power plant!'),
31 tokenPrefix: '0x0002030',31 tokenPrefix: '0x0002030',
32 offchainSchema: '0x111111',32 offchainSchema: '0x111111',
33 schemaVersion: 'Unique',33 schemaVersion: 'Unique',
40 });40 });
41 const events = await submitTransactionAsync(alice, tx);41 const events = await submitTransactionAsync(alice, tx);
42 const result = getCreateCollectionResult(events);42 const result = getCreateCollectionResult(events);
43 collection_id = result.collectionId;43 collectionId = result.collectionId;
4444
45 // Get the pre-upgrade collection info45 // Get the pre-upgrade collection info
46 collection_old = (await api.query.common.collectionById(collection_id)).toJSON();46 collectionOld = (await api.query.common.collectionById(collectionId)).toJSON();
4747
48 // Get the pre-upgrade spec version48 // Get the pre-upgrade spec version
49 old_version = (api.consts.system.version.toJSON() as any).specVersion;49 oldVersion = (api.consts.system.version.toJSON() as any).specVersion;
50 });50 });
5151
52 console.log(`Now waiting for the parachain upgrade from ${old_version!}...`);52 console.log(`Now waiting for the parachain upgrade from ${oldVersion!}...`);
5353
54 let new_version = old_version!;54 let newVersion = oldVersion!;
55 let connection_fail_counter = 0;55 let connectionFailCounter = 0;
56
57 // Cooperate with polkadot-launch if it's running (assuming custom name change), and send a custom signal
58 const find = require('find-process');
59 find('name', 'polkadot-launch', true).then(function (list: [any]) {
60 for (let proc of list) {
61 process.kill(proc.pid, 'SIGUSR1');
62 }
63 })
5664
57 // And wait for the parachain upgrade65 // And wait for the parachain upgrade
58 while (new_version == old_version! && connection_fail_counter < 2) {66 while (newVersion == oldVersion! && connectionFailCounter < 2) {
59 try {67 try {
60 await usingApi(async api => {68 await usingApi(async api => {
61 await waitNewBlocks(api);69 await waitNewBlocks(api);
62 new_version = (api.consts.system.version.toJSON() as any).specVersion;70 newVersion = (api.consts.system.version.toJSON() as any).specVersion;
63 });71 });
64 } catch (_) {72 } catch (_) {
65 connection_fail_counter++;73 connectionFailCounter++;
66 await new Promise( resolve => setTimeout(resolve, 12000) );74 await new Promise(resolve => setTimeout(resolve, 12000));
67 }75 }
68 }76 }
6977
70 await usingApi(async api => {78 await usingApi(async api => {
71 const collection_new = (await api.query.common.collectionById(collection_id)).toJSON() as any;79 const collectionNew = (await api.query.common.collectionById(collectionId)).toJSON() as any;
72 80
73 // Make sure the extra fields are what they should be81 // Make sure the extra fields are what they should be
74 const variable_on_chain_schema = await api.query.common.collectionData(collection_id, "VariableOnChainSchema");82 const variableOnChainSchema = await api.query.common.collectionData(collectionId, 'VariableOnChainSchema');
75 const const_on_chain_schema = await api.query.common.collectionData(collection_id, "ConstOnChainSchema");83 const constOnChainSchema = await api.query.common.collectionData(collectionId, 'ConstOnChainSchema');
76 const offchain_schema = await api.query.common.collectionData(collection_id, "OffchainSchema");84 const offchainSchema = await api.query.common.collectionData(collectionId, 'OffchainSchema');
7785
78 expect(variable_on_chain_schema.toHex()).to.be.deep.equal((collection_old.variableOnChainSchema));86 expect(variableOnChainSchema.toHex()).to.be.deep.equal((collectionOld.variableOnChainSchema));
79 expect(const_on_chain_schema.toHex()).to.be.deep.equal(collection_old.constOnChainSchema);87 expect(constOnChainSchema.toHex()).to.be.deep.equal(collectionOld.constOnChainSchema);
80 expect(offchain_schema.toHex()).to.be.deep.equal(collection_old.offchainSchema);88 expect(offchainSchema.toHex()).to.be.deep.equal(collectionOld.offchainSchema);
81 expect(collection_new).to.have.nested.property('limits.nestingRule');89 expect(collectionNew).to.have.nested.property('limits.nestingRule');
8290
83 // Get rid of extra fields to perform comparison on the rest of the collection91 // Get rid of extra fields to perform comparison on the rest of the collection
84 delete collection_new.limits.nestingRule;92 delete collectionNew.limits.nestingRule;
85 delete collection_old.constOnChainSchema;93 delete collectionOld.constOnChainSchema;
86 delete collection_old.offchainSchema;94 delete collectionOld.offchainSchema;
87 delete collection_old.variableOnChainSchema;95 delete collectionOld.variableOnChainSchema;
8896
89 expect(collection_new).to.be.deep.equal(collection_old);97 expect(collectionNew).to.be.deep.equal(collectionOld);
90 });98 });
91 });99 });
92});100});
modifiedtests/yarn.lockdiffbeforeafterboth
--- a/tests/yarn.lock
+++ b/tests/yarn.lock
@@ -3698,6 +3698,11 @@
   resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
   integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==
 
+commander@^5.1.0:
+  version "5.1.0"
+  resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
+  integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
+
 commander@^7.2.0:
   version "7.2.0"
   resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
@@ -5054,6 +5059,15 @@
   resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4"
   integrity sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=
 
+find-process@^1.4.7:
+  version "1.4.7"
+  resolved "https://registry.yarnpkg.com/find-process/-/find-process-1.4.7.tgz#8c76962259216c381ef1099371465b5b439ea121"
+  integrity sha512-/U4CYp1214Xrp3u3Fqr9yNynUrr5Le4y0SsJh2lMDDSbpwYSz3M2SMWQC+wqcx79cN8PQtHQIL8KnuY9M66fdg==
+  dependencies:
+    chalk "^4.0.0"
+    commander "^5.1.0"
+    debug "^4.1.1"
+
 find-up@5.0.0:
   version "5.0.0"
   resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"