difftreelog
refactor(zombienet) minor ease of access improvements
in: master
1 file changed
tests/src/util/frankenstein.tsdiffbeforeafterboth89 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}979798const 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 point102 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 */108108109 // an unsavory practice, but very convenient, mwahahah109 // an unsavory practice, but very convenient, mwahahah110 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 }136138137 // non-exported functionality of NativeClient139 // non-exported functionality of NativeClient138 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');198200199 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 );206207 if (result.status == 'Fail') {208 console.error('Failed to upgrade the runtime:', result);209 }204210205 // Get the updated information from the relay's new runtime211 // Get the updated information from the relay's new runtime206 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};253259254 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 );266267 if (result.status == 'Fail') {268 console.error('Failed to authorize the upgrade:', result);269 return;270 }260271261 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 );278279 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 }269284315330316 // await network.stop();331 // await network.stop();317332318 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};326343327raiseZombienet()/*.then(async () => await stop())*/.catch(async (e) => {344raiseZombienet()/*.then(async () => await stop())*/.catch(async (e) => {