Skip to content

Add zombienet battery station client upgrade test #1350

@Chralt98

Description

@Chralt98

Currently only the client upgrade of the zeitgeist main-net is tested before applying upgrades to the networks.

describeSuite({
id: "R01",
title: "Zombie Zeitgeist Upgrade Test",
foundationMethods: "zombie",
testCases: function ({ it, context, log }) {
let paraApi: ApiPromise;
let relayApi: ApiPromise;
let alice: KeyringPair;
beforeAll(async () => {
const keyring = new Keyring({ type: "sr25519" });
alice = keyring.addFromUri("//Alice", { name: "Alice default" });
paraApi = context.polkadotJs("parachain");
relayApi = context.polkadotJs("Relay");
const relayNetwork = (
relayApi.consts.system.version as unknown as RuntimeVersion
).specName.toString();
expect(relayNetwork, "Relay API incorrect").to.contain("rococo");
const paraNetwork = (
paraApi.consts.system.version as unknown as RuntimeVersion
).specName.toString();
expect(paraNetwork, "Para API incorrect").to.contain("zeitgeist");
const currentBlock = (
await paraApi.rpc.chain.getBlock()
).block.header.number.toNumber();
expect(currentBlock, "Parachain not producing blocks").to.be.greaterThan(
0
);
}, 120000);
it({
id: "T01",
title: "Blocks are being produced on parachain",
test: async function () {
const blockNum = (
await paraApi.rpc.chain.getBlock()
).block.header.number.toNumber();
expect(blockNum).to.be.greaterThan(0);
},
});
it({
id: "T02",
title: "Chain can be upgraded",
timeout: 600000,
test: async function () {
const blockNumberBefore = (
await paraApi.rpc.chain.getBlock()
).block.header.number.toNumber();
const currentCode = await paraApi.rpc.state.getStorage(":code");
const codeString = currentCode.toString();
const moonwallContext = await MoonwallContext.getContext();
log(
"Moonwall Context providers: " +
moonwallContext.providers.map((p) => p.name).join(", ")
);
const wasm = fs.readFileSync(moonwallContext.rtUpgradePath);
const rtHex = `0x${wasm.toString("hex")}`;
if (rtHex === codeString) {
log("Runtime already upgraded, skipping test");
return;
} else {
log("Runtime not upgraded, proceeding with test");
log(
"Current runtime hash: " +
rtHex.slice(0, 10) +
"..." +
rtHex.slice(-10)
);
log(
"New runtime hash: " +
codeString.slice(0, 10) +
"..." +
codeString.slice(-10)
);
}
await context.upgradeRuntime({ from: alice, logger: log });
await context.waitBlock(2);
const blockNumberAfter = (
await paraApi.rpc.chain.getBlock()
).block.header.number.toNumber();
log(`Before: #${blockNumberBefore}, After: #${blockNumberAfter}`);
expect(
blockNumberAfter,
"Block number did not increase"
).to.be.greaterThan(blockNumberBefore);
},
});
},
});

Ideally the battery station upgrade for the client should also be tested using zombienet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    l:SSolving this issue takes hoursp:highHigh priority, prioritize the resolution of this issuet:enhancementThe issue described an enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions