mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 16:01:04 +00:00
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>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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 }
|
||||
Reference in New Issue
Block a user