Skip to content

Commit 2c138ed

Browse files
authored
zombienet doesnt require connected parachains (#438)
* zombienet doesnt require connected parachains * prescript errors halt runs
1 parent cbb72a2 commit 2c138ed

File tree

11 files changed

+175
-51
lines changed

11 files changed

+175
-51
lines changed

.changeset/olive-lions-enjoy.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@moonwall/cli": minor
3+
"@moonwall/tests": minor
4+
"@moonwall/types": minor
5+
"@moonwall/util": minor
6+
---
7+
8+
November Update
9+
- [[#435](https://github.com/Moonsong-Labs/moonwall/issues/435)] Zombienets dont require parachains anymore
10+
- [[#408](https://github.com/Moonsong-Labs/moonwall/issues/408)] preScript failures halt test runs

.github/workflows/main.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ jobs:
219219
strategy:
220220
fail-fast: false
221221
matrix:
222-
suite: ["zombie_test", "zombie_multi_para"]
222+
suite: ["zombie_test", "zombie_multi_para", "zombie_noPara"]
223223
steps:
224224
- uses: actions/checkout@v4
225225
- uses: pnpm/action-setup@v4
@@ -241,10 +241,9 @@ jobs:
241241
cd test
242242
bun moonwall download moonbeam latest ./tmp
243243
244-
# Change these to latest once MB is compatible with 1.2.0
245-
bun moonwall download polkadot 1.8.0 ./tmp
246-
bun moonwall download polkadot-execute-worker 1.8.0 ./tmp
247-
bun moonwall download polkadot-prepare-worker 1.8.0 ./tmp
244+
bun moonwall download polkadot stable2407 ./tmp
245+
bun moonwall download polkadot-execute-worker stable2407 ./tmp
246+
bun moonwall download polkadot-prepare-worker stable2407 ./tmp
248247
- name: Run ${{matrix.suite}}
249248
run: |
250249
cd test

packages/cli/src/cmds/runTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Environment } from "@moonwall/types";
22
import chalk from "chalk";
33
import path from "node:path";
4-
import type { UserConfig, Vitest } from "vitest";
4+
import type { UserConfig, Vitest } from "vitest/node";
55
import { startVitest } from "vitest/node";
66
import { clearNodeLogs } from "../internal/cmdFunctions/tempLogs";
77
import { commonChecks } from "../internal/launcherCommon";

packages/cli/src/internal/foundations/zombieHelpers.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,41 @@ export async function checkZombieBins(config: LaunchConfig) {
1515
await checkExists(relayBinPath);
1616
checkAccess(relayBinPath);
1717

18-
const promises = config.parachains.map((para) => {
19-
if (para.collator) {
20-
if (!para.collator.command) {
21-
throw new Error(
22-
"No command found for collator, please check your zombienet config file for collator command"
23-
);
24-
}
25-
checkExists(para.collator.command);
26-
checkAccess(para.collator.command);
27-
}
28-
29-
if (para.collators) {
30-
for (const coll of para.collators) {
31-
if (!coll.command) {
18+
if (config.parachains) {
19+
const promises = config.parachains.map((para) => {
20+
if (para.collator) {
21+
if (!para.collator.command) {
3222
throw new Error(
33-
"No command found for collators, please check your zombienet config file for collators command"
23+
"No command found for collator, please check your zombienet config file for collator command"
3424
);
3525
}
36-
checkExists(coll.command);
37-
checkAccess(coll.command);
26+
checkExists(para.collator.command);
27+
checkAccess(para.collator.command);
3828
}
39-
// para.collators.forEach((coll) => {
40-
// if (!coll.command) {
41-
// throw new Error(
42-
// "No command found for collators, please check your zombienet config file for para collators command"
43-
// );
44-
// }
45-
// checkExists(coll.command);
46-
// checkAccess(coll.command);
47-
// });
48-
}
49-
});
50-
await Promise.all(promises);
29+
30+
if (para.collators) {
31+
for (const coll of para.collators) {
32+
if (!coll.command) {
33+
throw new Error(
34+
"No command found for collators, please check your zombienet config file for collators command"
35+
);
36+
}
37+
checkExists(coll.command);
38+
checkAccess(coll.command);
39+
}
40+
// para.collators.forEach((coll) => {
41+
// if (!coll.command) {
42+
// throw new Error(
43+
// "No command found for collators, please check your zombienet config file for para collators command"
44+
// );
45+
// }
46+
// checkExists(coll.command);
47+
// checkAccess(coll.command);
48+
// });
49+
}
50+
});
51+
await Promise.all(promises);
52+
}
5153
}
5254

5355
export function getZombieConfig(path: string) {

packages/cli/src/internal/launcherCommon.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export async function executeScript(scriptCommand: string, args?: string) {
8484
default:
8585
console.log(`${ext} not supported, skipping ${script}`);
8686
}
87-
} catch (err) {
87+
} catch (err: any) {
8888
console.error(`Error executing script: ${chalk.bgGrey.redBright(err)}`);
89+
throw new Error(err);
8990
}
9091
}

packages/cli/src/internal/providerFactories.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class ProviderFactory {
149149
public static prepareDefaultZombie(): MoonwallProvider[] {
150150
const MOON_PARA_WSS = process.env.MOON_PARA_WSS || "error";
151151
const MOON_RELAY_WSS = process.env.MOON_RELAY_WSS || "error";
152-
return ProviderFactory.prepare([
152+
const providers = [
153153
{
154154
name: "w3",
155155
type: "web3",
@@ -165,34 +165,45 @@ export class ProviderFactory {
165165
type: "viem",
166166
endpoints: [MOON_PARA_WSS],
167167
},
168-
{
169-
name: "parachain",
170-
type: "polkadotJs",
171-
endpoints: [MOON_PARA_WSS],
172-
},
168+
173169
{
174170
name: "relaychain",
175171
type: "polkadotJs",
176172
endpoints: [MOON_RELAY_WSS],
177173
},
178-
]);
174+
] satisfies ProviderConfig[];
175+
176+
if (MOON_PARA_WSS !== "error") {
177+
providers.push({
178+
name: "parachain",
179+
type: "polkadotJs",
180+
endpoints: [MOON_PARA_WSS],
181+
});
182+
}
183+
184+
return ProviderFactory.prepare(providers);
179185
}
180186

181187
public static prepareNoEthDefaultZombie(): MoonwallProvider[] {
182188
const MOON_PARA_WSS = process.env.MOON_PARA_WSS || "error";
183189
const MOON_RELAY_WSS = process.env.MOON_RELAY_WSS || "error";
184-
return ProviderFactory.prepare([
185-
{
186-
name: "parachain",
187-
type: "polkadotJs",
188-
endpoints: [MOON_PARA_WSS],
189-
},
190+
191+
const providers = [
190192
{
191193
name: "relaychain",
192194
type: "polkadotJs",
193195
endpoints: [MOON_RELAY_WSS],
194196
},
195-
]);
197+
] satisfies ProviderConfig[];
198+
199+
if (MOON_PARA_WSS !== "error") {
200+
providers.push({
201+
name: "parachain",
202+
type: "polkadotJs",
203+
endpoints: [MOON_PARA_WSS],
204+
});
205+
}
206+
return ProviderFactory.prepare(providers);
196207
}
197208
}
198209

packages/cli/src/lib/globalContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ export class MoonwallContext {
208208
};
209209

210210
process.env.MOON_RELAY_WSS = network.relay[0].wsUri;
211-
process.env.MOON_PARA_WSS = Object.values(network.paras)[0].nodes[0].wsUri;
211+
212+
if (Object.entries(network.paras).length > 0) {
213+
process.env.MOON_PARA_WSS = Object.values(network.paras)[0].nodes[0].wsUri;
214+
}
212215

213216
const nodeNames = Object.keys(network.nodesByName);
214217
process.env.MOON_ZOMBIE_DIR = `${network.tmpDir}`;

test/configs/zombieNoPara.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"settings": {
3+
"timeout": 1000,
4+
"provider": "native"
5+
},
6+
"relaychain": {
7+
"chain": "rococo-local",
8+
"default_command": "tmp/polkadot",
9+
"default_args": [
10+
"--no-hardware-benchmarks",
11+
"-lparachain=debug",
12+
"--database=paritydb"
13+
],
14+
"nodes": [
15+
{
16+
"name": "alice",
17+
"validator": true
18+
},
19+
{
20+
"name": "bob",
21+
"validator": true
22+
}
23+
]
24+
},
25+
"types": {
26+
"Header": {
27+
"number": "u64",
28+
"parent_hash": "Hash",
29+
"post_state": "Hash"
30+
}
31+
}
32+
}

test/moonwall.config.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@
7878
]
7979
}
8080
},
81+
{
82+
"name": "failing_prescript",
83+
"testFileDir": ["suites/basic"],
84+
"description": "Test that failing pre-scripts are caught",
85+
"runScripts": ["failing-script.ts"],
86+
"foundation": {
87+
"type": "read_only",
88+
"launchSpec": {
89+
"disableRuntimeVersionCheck": true
90+
}
91+
},
92+
"connections": []
93+
},
8194
{
8295
"name": "dev_tanssi",
8396
"testFileDir": ["suites/tanssi"],
@@ -168,6 +181,25 @@
168181
}
169182
}
170183
},
184+
{
185+
"name": "zombie_noPara",
186+
"testFileDir": ["suites/zombieNoPara"],
187+
"timeout": 300000,
188+
"envVars": ["DEBUG_COLORS=1"],
189+
"reporters": ["default"],
190+
"foundation": {
191+
"type": "zombie",
192+
"zombieSpec": {
193+
"name": "zombienet",
194+
"disableDefaultEthProviders": true,
195+
"additionalZombieConfig": {
196+
"silent": true
197+
},
198+
"configPath": "./configs/zombieNoPara.json"
199+
}
200+
}
201+
},
202+
171203
{
172204
"name": "para_test",
173205
"testFileDir": ["suites/zombie"],

test/scripts/failing-script.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.log("This script will fail on purpose.")
2+
3+
process.exit(1)

0 commit comments

Comments
 (0)