git.delta.rocks / unique-network / refs/commits / 48f9af6da8fb

difftreelog

refactor(zombienet) minor ease of access improvements

Fahrrader2023-04-28parent: #2a5333f.patch.diff
in: master

1 file changed

modifiedtests/src/util/frankenstein.tsdiffbeforeafterboth
89 const toggle = value ? 'enable' : 'disable';89 const toggle = value ? 'enable' : 'disable';
90 await helper.getSudo().executeExtrinsic(superuser, `api.tx.maintenance.${toggle}`, []);90 await helper.getSudo().executeExtrinsic(superuser, `api.tx.maintenance.${toggle}`, []);
91 console.log(`Maintenance mode ${value ? 'engaged' : 'disengaged'}.`);91 console.log(`Maintenance mode ${value ? 'engaged' : 'disengaged'}.`);
92 } catch (_) {92 } catch (e) {
93 console.error('Couldn\'t set maintenance mode. The maintenance pallet probably does not exist.');93 console.error('Couldn\'t set maintenance mode. The maintenance pallet probably does not exist. Log:', e);
94 }94 }
95 }, wsUri);95 }, wsUri);
96}96}
9797
98const raiseZombienet = async (): Promise<void> => {98const raiseZombienet = async (): Promise<void> => {
99 const upgradeTesting = !!NEW_RELAY_BIN || !!NEW_RELAY_WASM || !!NEW_RELAY_BIN && !!NEW_PARA_WASM;99 const isUpgradeTesting = !!NEW_RELAY_BIN || !!NEW_RELAY_WASM || !!NEW_RELAY_BIN && !!NEW_PARA_WASM;
100 /*100 /*
101 // If there is nothing to upgrade, what is the point101 // If there is nothing to upgrade, what is the point
102 if (!upgradeTesting) {102 if (!isUpgradeTesting) {
103 console.warn('\nNeither the relay nor the parachain were selected for an upgrade! ' +103 console.warn('\nNeither the relay nor the parachain were selected for an upgrade! ' +
104 'Please pass environment vars `NEW_RELAY_BIN`, `NEW_RELAY_WASM`, `NEW_PARA_BIN`, `NEW_PARA_WASM`.');104 'Please pass environment vars `NEW_RELAY_BIN`, `NEW_RELAY_WASM`, `NEW_PARA_BIN`, `NEW_PARA_WASM`.');
105 process.exit(1);105 process.exit(1);
106 }106 }
107 */107 */
108108
109 // an unsavory practice, but very convenient, mwahahah109 // an unsavory practice, but very convenient, mwahahah
110 process.env.PARA_DIR = PARA_DIR;110 process.env.PARA_DIR = PARA_DIR;
132 await network.relay[0].connectApi();132 await network.relay[0].connectApi();
133 let relayInfo = getRelayInfo(network.relay[0].apiInstance!);133 let relayInfo = getRelayInfo(network.relay[0].apiInstance!);
134 await network.relay[0].apiInstance?.disconnect();134 await network.relay[0].apiInstance?.disconnect();
135 if (isUpgradeTesting) {
135 console.log(relayInfo);136 console.log('Relay stats:', relayInfo);
137 }
136138
137 // non-exported functionality of NativeClient139 // non-exported functionality of NativeClient
138 const networkClient = (network.client as any);140 const networkClient = (network.client as any);
196 await usingPlaygrounds(async (helper, privateKey) => {198 await usingPlaygrounds(async (helper, privateKey) => {
197 const superuser = await privateKey('//Alice');199 const superuser = await privateKey('//Alice');
198200
199 await helper.executeExtrinsic(201 const result = await helper.executeExtrinsic(
200 superuser,202 superuser,
201 'api.tx.sudo.sudoUncheckedWeight',203 'api.tx.sudo.sudoUncheckedWeight',
202 [helper.constructApiCall('api.tx.system.setCode', [`0x${code}`]), 0],204 [helper.constructApiCall('api.tx.system.setCode', [`0x${code}`]), 0],
203 );205 );
206
207 if (result.status == 'Fail') {
208 console.error('Failed to upgrade the runtime:', result);
209 }
204210
205 // Get the updated information from the relay's new runtime211 // Get the updated information from the relay's new runtime
206 relayInfo = getRelayInfo(helper.getApi());212 relayInfo = getRelayInfo(helper.getApi());
252 upgradingParas[paraId] = {version: getSpecVersion(helper.getApi()), upgraded: false};258 upgradingParas[paraId] = {version: getSpecVersion(helper.getApi()), upgraded: false};
253259
254 console.log('--- Authorizing the parachain runtime upgrade \t---');260 console.log('--- Authorizing the parachain runtime upgrade \t---');
255 await helper.executeExtrinsic(261 let result = await helper.executeExtrinsic(
256 superuser,262 superuser,
257 'api.tx.sudo.sudoUncheckedWeight',263 'api.tx.sudo.sudoUncheckedWeight',
258 [helper.constructApiCall('api.tx.parachainSystem.authorizeUpgrade', [codeHash]), 0],264 [helper.constructApiCall('api.tx.parachainSystem.authorizeUpgrade', [codeHash]), 0],
259 );265 );
266
267 if (result.status == 'Fail') {
268 console.error('Failed to authorize the upgrade:', result);
269 return;
270 }
260271
261 console.log('--- Enacting the parachain runtime upgrade \t---');272 console.log('--- Enacting the parachain runtime upgrade \t---');
262 await helper.executeExtrinsic(273 result = await helper.executeExtrinsic(
263 superuser,274 superuser,
264 'api.tx.sudo.sudoUncheckedWeight',275 'api.tx.sudo.sudoUncheckedWeight',
265 [helper.constructApiCall('api.tx.parachainSystem.enactAuthorizedUpgrade', [`0x${code.toString('hex')}`]), 0],276 [helper.constructApiCall('api.tx.parachainSystem.enactAuthorizedUpgrade', [`0x${code.toString('hex')}`]), 0],
266 );277 );
278
279 if (result.status == 'Fail') {
280 console.error('Failed to upgrade the runtime:', result);
281 }
267 }, para.nodes[0].wsUri);282 }, para.nodes[0].wsUri);
268 }283 }
269284
315330
316 // await network.stop();331 // await network.stop();
317332
318 if (upgradeTesting) {333 if (isUpgradeTesting) {
319 if (paraUpgradeCompleted && relayUpgradeCompleted) {334 if (paraUpgradeCompleted && relayUpgradeCompleted) {
320 console.log("\n🛸 PARACHAINS' RUNTIME UPGRADE TESTING COMPLETE 🛸");335 console.log("\n🛸 PARACHAINS' RUNTIME UPGRADE TESTING COMPLETE 🛸");
321 } else {336 } else {
322 console.error("\n🚧 PARACHAINS' RUNTIME UPGRADE TESTING FAILED 🚧");337 console.error("\n🚧 PARACHAINS' RUNTIME UPGRADE TESTING FAILED 🚧");
323 }338 }
324 }339 } else {
340 console.log('🚀 ZOMBIENET RAISED 🚀');
341 }
325};342};
326343
327raiseZombienet()/*.then(async () => await stop())*/.catch(async (e) => {344raiseZombienet()/*.then(async () => await stop())*/.catch(async (e) => {