Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Unable to map [u8; 32] to a lookup index
pnpm exec moonwall test zombienet_zeitgeist_upgrade --runInBand
```

#### Test the upgrade to the WASM from `./target/release/wbuild/battery-station-runtime` on zombienet:

```bash
pnpm exec moonwall test zombienet_battery_station_upgrade --runInBand
```

#### Test the upgrade to the WASM from `./target/release/wbuild/zeitgeist-runtime` on the live main-net fork using chopsticks:

```bash
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/configs/hydradx.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
endpoint: wss://rpc.hydradx.cloud/public-ws
endpoint:
- wss://hydration-rpc.n.dwellir.com
- wss://hydration.ibp.network
- wss://rpc.helikon.io/hydradx
- wss://hydration.dotters.network
mock-signature-host: true
block: ${env.HYDRADX_BLOCK_NUMBER}
db: ./tmp/hydradx_db_mba.sqlite
Expand Down
45 changes: 45 additions & 0 deletions integration-tests/configs/zombieBatteryStation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"chain": "rococo-local",
"default_command": "./tmp/polkadot",
"default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy", "--detailed-log-output"],
"nodes": [
{
"name": "charlie",
"rpc_port": 9947,
"validator": true
},
{
"name": "bob",
"rpc_port": 9950,
"validator": true
}
]
},
"parachains": [
{
"id": 2101,
"chain": "dev",
"collators": [
{
"name": "alice",
"command": "../target/release/zeitgeist",
"rpc_port": 9944,
"p2p_port": 33049,
"args": ["-lparachain=debug", "--force-authoring", "--detailed-log-output"]
}
]
}
],
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
90 changes: 50 additions & 40 deletions integration-tests/configs/zombieZeitgeist.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,55 @@
{
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"chain": "rococo-local",
"default_command": "./tmp/polkadot",
"default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy", "--detailed-log-output"],
"nodes": [
{
"name": "charlie",
"rpc_port": 9947,
"validator": true
},
{
"name": "bob",
"rpc_port": 9950,
"validator": true
}
]
},
"parachains": [
{
"id": 2101,
"chain": "dev",
"collators": [
{
"name": "alice",
"command": "../target/release/zeitgeist",
"rpc_port": 9944,
"p2p_port": 33049,
"args": ["-lparachain=debug", "--force-authoring", "--detailed-log-output"]
}
]
}
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"chain": "rococo-local",
"default_command": "./tmp/polkadot",
"default_args": [
"--no-hardware-benchmarks",
"-lparachain=debug",
"--database=paritydb",
"--no-beefy",
"--detailed-log-output"
],
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
"nodes": [
{
"name": "charlie",
"rpc_port": 9957,
"validator": true
},
{
"name": "bob",
"rpc_port": 9960,
"validator": true
}
]
},
"parachains": [
{
"id": 2092,
"chain": "./zeitgeist-parachain-2092.json",
"collators": [
{
"name": "alice",
"command": "../target/release/zeitgeist",
"rpc_port": 9954,
"p2p_port": 33059,
"args": [
"-lparachain=debug",
"--force-authoring",
"--detailed-log-output"
]
}
]
}
],
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
37 changes: 35 additions & 2 deletions integration-tests/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@
"defaultTestTimeout": 120000,
"scriptsDir": "scripts/",
"environments": [
{
"name": "zombienet_battery_station_upgrade",
"testFileDir": ["tests/rt-upgrade-zombienet"],
"runScripts": [
"build-node.sh",
"build-zeitgeist-spec.sh",
"download-polkadot.sh"
],
"foundation": {
"launchSpec": [
{
"binPath": "../target/release/zeitgeist"
}
],
"rtUpgradePath": "../target/release/wbuild/battery-station-runtime/battery_station_runtime.compact.compressed.wasm",
"type": "zombie",
"zombieSpec": {
"configPath": "./configs/zombieBatteryStation.json"
}
},
"connections": [
{
"name": "Relay",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9947"]
},
{
"name": "parachain",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9944"]
}
]
},
{
"name": "zombienet_zeitgeist_upgrade",
"testFileDir": ["tests/rt-upgrade-zombienet"],
Expand All @@ -27,12 +60,12 @@
{
"name": "Relay",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9947"]
"endpoints": ["ws://127.0.0.1:9957"]
},
{
"name": "parachain",
"type": "polkadotJs",
"endpoints": ["ws://127.0.0.1:9944"]
"endpoints": ["ws://127.0.0.1:9954"]
}
]
},
Expand Down
1 change: 1 addition & 0 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@polkadot/api": "16.5.2",
"@polkadot/keyring": "13.5.2",
"@polkadot/types": "16.5.2",
"@polkadot/util": "13.5.2",
"@polkadot/util-crypto": "13.5.2",
"@types/node": "22.10.2",
"debug": "4.3.4",
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/pnpm-lock.yaml

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

62 changes: 60 additions & 2 deletions integration-tests/scripts/build-zeitgeist-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,68 @@
# SPDX-License-Identifier: GPL-3.0-or-later

# Exit on any error
set -e
set -euo pipefail

# Always run the commands from the "integration-tests" dir
cd $(dirname $0)/..

mkdir -p specs
../target/release/zeitgeist build-spec --chain=zeitgeist --raw > specs/zeitgeist-parachain-2092.json
# Start from the dev plain spec so zombienet can customize it. Avoid parsing
# and re-stringifying the whole JSON (which can switch large integers into
# exponent form) by doing targeted string replacements.
tmp_spec="$(mktemp)"
../target/release/zeitgeist build-spec --chain=dev --disable-default-bootnode > "${tmp_spec}"

out_path="$(pwd)/zeitgeist-parachain-2092.json"

node - "${tmp_spec}" "${out_path}" <<'NODE'
const fs = require("fs");
const path = require("path");
const [,, inPath, outPath] = process.argv;
if (!inPath || !outPath) {
console.error("spec path arg missing");
process.exit(1);
}

let text = fs.readFileSync(inPath, "utf8");
const replace = (pattern, replacement, label) => {
const next = text.replace(pattern, replacement);
if (next === text) {
console.error(`WARN: pattern not replaced (${label})`);
}
text = next;
};

replace(/"name"\s*:\s*"[^"]*"/, '"name": "Zeitgeist Rococo Local"', "name");
replace(/"id"\s*:\s*"[^"]*"/, '"id": "zeitgeist_rococo_local"', "id");
replace(/"relay_chain"\s*:\s*"[^"]*"/, '"relay_chain": "rococo-local"', "relay_chain");
replace(/"parachain_id"\s*:\s*\d+/, '"parachain_id": 2092', "parachain_id");
replace(/"chainType"\s*:\s*"[^"]*"/, '"chainType": "Local"', "chainType");
replace(/"bootNodes"\s*:\s*\[[\s\S]*?\]/, '"bootNodes": []', "bootNodes");
replace(/"telemetryEndpoints"\s*:\s*(\[[\s\S]*?\]|null)/, '"telemetryEndpoints": null', "telemetryEndpoints");
replace(/"protocolId"\s*:\s*(null|"[^"]*")/, '"protocolId": "zeitgeist-rococo"', "protocolId");
replace(/"ss58Format"\s*:\s*\d+/, '"ss58Format": 73', "ss58Format");
replace(/"tokenDecimals"\s*:\s*[^,}\n]+/, '"tokenDecimals": 10', "tokenDecimals");
replace(/"tokenSymbol"\s*:\s*"[^"]*"/, '"tokenSymbol": "ZTG"', "tokenSymbol");
replace(/("parachainInfo"\s*:\s*\{\s*"parachainId"\s*:\s*)\d+/, "$1 2092", "parachainInfo.parachainId");

fs.writeFileSync(outPath, text);
console.log(`Wrote ${outPath}`);

// Keep the runtime wasm that Moonwall will upload in sync with the code baked
// into the genesis so the upgrade test compares against the correct artifact.
try {
const spec = JSON.parse(text);
const codeHex = spec?.genesis?.runtimeGenesis?.code || spec?.genesis?.runtime?.code;
if (typeof codeHex === "string" && codeHex.startsWith("0x")) {
const wasmPath = path.resolve(process.cwd(), "../target/release/wbuild/zeitgeist-runtime/zeitgeist_runtime.compact.compressed.wasm");
fs.mkdirSync(path.dirname(wasmPath), { recursive: true });
fs.writeFileSync(wasmPath, Buffer.from(codeHex.slice(2), "hex"));
console.log(`Wrote runtime wasm to ${wasmPath}`);
} else {
console.error("WARN: runtime code not found in spec; skipping wasm write");
}
} catch (err) {
console.error("WARN: failed to parse spec JSON to write wasm", err?.message || err);
}
NODE
4 changes: 4 additions & 0 deletions integration-tests/scripts/download-polkadot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ delete_if_not_binary "tmp/polkadot-prepare-worker"

if [[ -x tmp/polkadot && -x tmp/polkadot-execute-worker && -x tmp/polkadot-prepare-worker ]]; then
POLKADOT_VERSION=$(tmp/polkadot --version || true)
if [[ -n "${POLKADOT_SKIP_DOWNLOAD:-}" ]]; then
echo "POLKADOT_SKIP_DOWNLOAD set; using existing polkadot binaries (${POLKADOT_VERSION:-unknown})."
exit 0
fi
if [[ "${POLKADOT_RELEASE}" == "latest" || "${POLKADOT_VERSION}" == *"${POLKADOT_RELEASE}"* ]]; then
echo "Polkadot binaries already match the requested release."
exit 0
Expand Down
Loading
Loading