Skip to content

Commit

Permalink
Merge branch 'master' into ahmad-evm-native-transfer-test
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ authored Oct 3, 2024
2 parents 7758e94 + 4bd16bf commit 6edd820
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 23 deletions.
6 changes: 3 additions & 3 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
{
"name": "mb",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:8000"]
"endpoints": ["ws://localhost:8000"]
}
]
},
Expand All @@ -656,7 +656,7 @@
{
"name": "mb",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:8000"]
"endpoints": ["ws://localhost:8000"]
}
]
},
Expand All @@ -679,7 +679,7 @@
{
"name": "mb",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:8000"]
"endpoints": ["ws://localhost:8000"]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@acala-network/chopsticks": "0.15.0",
"@acala-network/chopsticks": "0.16.1",
"@moonbeam-network/api-augment": "0.2902.0",
"@moonwall/cli": "5.3.3",
"@moonwall/util": "5.3.3",
Expand Down
34 changes: 17 additions & 17 deletions test/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 51 additions & 2 deletions test/suites/chopsticks/test-upgrade-chain.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
import "@moonbeam-network/api-augment";
import { MoonwallContext, beforeAll, describeSuite, expect } from "@moonwall/cli";
import {
MoonwallContext,
beforeAll,
describeSuite,
expect,
ChopsticksContext,
} from "@moonwall/cli";
import { alith } from "@moonwall/util";
import { ApiPromise } from "@polkadot/api";
import { HexString } from "@polkadot/util/types";
import { u32 } from "@polkadot/types";
import { hexToU8a, u8aConcat, u8aToHex } from "@polkadot/util";
import { blake2AsHex, xxhashAsU8a } from "@polkadot/util-crypto";
import { parseEther } from "ethers";
import { existsSync, readFileSync } from "node:fs";

const hash = (prefix: HexString, suffix: Uint8Array) => {
return u8aToHex(u8aConcat(hexToU8a(prefix), xxhashAsU8a(suffix, 64), suffix));
};

const upgradeRestrictionSignal = (paraId: u32) => {
const prefix = "0xcd710b30bd2eab0352ddcc26417aa194f27bbb460270642b5bcaf032ea04d56a";

return hash(prefix, paraId.toU8a());
};

const upgradeRuntime = async (context: ChopsticksContext) => {
const path = (await MoonwallContext.getContext()).rtUpgradePath;
if (!existsSync(path)) {
throw new Error(`Runtime wasm not found at path: ${path}`);
}
const rtWasm = readFileSync(path);
const rtHex = `0x${rtWasm.toString("hex")}`;
const rtHash = blake2AsHex(rtHex);
const api = context.polkadotJs();
const signer = context.keyring.alice;

await context.setStorage({
module: "system",
method: "authorizedUpgrade",
methodParams: `${rtHash}01`, // 01 is for the RT ver check = true
});
await context.createBlock();

await api.tx.system.applyAuthorizedUpgrade(rtHex).signAndSend(signer);

const paraId: u32 = await api.query.parachainInfo.parachainId();

await api.rpc("dev_newBlock", {
count: 3,
relayChainStateOverrides: [[upgradeRestrictionSignal(paraId), null]],
});
};

describeSuite({
id: "C01",
Expand All @@ -19,7 +68,7 @@ describeSuite({
log("About to upgrade to runtime at:");
log((await MoonwallContext.getContext()).rtUpgradePath);

await context.upgradeRuntime();
await upgradeRuntime(context);

const rtafter = api.consts.system.version.specVersion.toNumber();
log(`RT upgrade has increased specVersion from ${rtBefore} to ${rtafter}`);
Expand Down

0 comments on commit 6edd820

Please sign in to comment.