Files
pezkuwi-subxt/zombienet/tests/runtime_upgrade.js
T
Sebastian Kunert f68e124a96 Add example zombienet network file and instructions (#1839)
* Add simple example on how to spin up network.

* Update readme

* Remove unnecessary prefix

* Improve folder structure

* Add link to file

* Fix paths in readme

* Update README.md

Co-authored-by: Bastian Köcher <git@kchr.de>

Co-authored-by: Bastian Köcher <git@kchr.de>
2022-11-08 18:26:20 +00:00

24 lines
1.1 KiB
JavaScript

const assert = require("assert");
async function run(nodeName, networkInfo, args) {
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);
// get blockhash/runtimeVersion at block 1
const hashAtBlock1 = await api.rpc.chain.getBlockHash(1);
const versionAtBlock1 = await api.rpc.state.getRuntimeVersion(hashAtBlock1.toHuman());
// get blockhash/runtimeVersion at current head
const currentHeader = await api.rpc.chain.getHeader();
const hashAtCurrent = await api.rpc.chain.getBlockHash(currentHeader.number.toHuman());
const versionAtCurrent = await api.rpc.state.getRuntimeVersion(hashAtCurrent.toHuman());
const oldVersionIncremented = parseInt(versionAtBlock1.specVersion.toHuman(),10) + 1;
console.log("current", versionAtCurrent.specVersion.toHuman());
console.log("oldVersionIncremented", oldVersionIncremented);
// 2 == 2
assert.equal( oldVersionIncremented, versionAtCurrent.specVersion.toHuman(), "Running version should be the incremented version");
}
module.exports = { run }