Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zombienet battery station client upgrade test #1350

Open
Chralt98 opened this issue Jul 30, 2024 · 0 comments
Open

Add zombienet battery station client upgrade test #1350

Chralt98 opened this issue Jul 30, 2024 · 0 comments
Labels
l:S Solving this issue takes hours p:high High priority, prioritize the resolution of this issue t:enhancement The issue described an enhancement

Comments

@Chralt98
Copy link
Member

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.

@Chralt98 Chralt98 added p:high High priority, prioritize the resolution of this issue t:enhancement The issue described an enhancement l:S Solving this issue takes hours labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
l:S Solving this issue takes hours p:high High priority, prioritize the resolution of this issue t:enhancement The issue described an enhancement
Projects
None yet
Development

No branches or pull requests

1 participant