Skip to content

Commit

Permalink
zombienet doesnt require connected parachains
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded committed Nov 13, 2024
1 parent cbb72a2 commit d676ba3
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 45 deletions.
9 changes: 9 additions & 0 deletions .changeset/olive-lions-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@moonwall/cli": minor
"@moonwall/tests": minor
"@moonwall/types": minor
"@moonwall/util": minor
---

November Update
- [[#435](https://github.com/Moonsong-Labs/moonwall/issues/435)] Zombienets dont require parachains anymore
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: ["zombie_test", "zombie_multi_para"]
suite: ["zombie_test", "zombie_multi_para", "zombie_noPara"]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand Down
60 changes: 31 additions & 29 deletions packages/cli/src/internal/foundations/zombieHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,41 @@ export async function checkZombieBins(config: LaunchConfig) {
await checkExists(relayBinPath);
checkAccess(relayBinPath);

const promises = config.parachains.map((para) => {
if (para.collator) {
if (!para.collator.command) {
throw new Error(
"No command found for collator, please check your zombienet config file for collator command"
);
}
checkExists(para.collator.command);
checkAccess(para.collator.command);
}

if (para.collators) {
for (const coll of para.collators) {
if (!coll.command) {
if (config.parachains) {
const promises = config.parachains.map((para) => {
if (para.collator) {
if (!para.collator.command) {
throw new Error(
"No command found for collators, please check your zombienet config file for collators command"
"No command found for collator, please check your zombienet config file for collator command"
);
}
checkExists(coll.command);
checkAccess(coll.command);
checkExists(para.collator.command);
checkAccess(para.collator.command);
}
// para.collators.forEach((coll) => {
// if (!coll.command) {
// throw new Error(
// "No command found for collators, please check your zombienet config file for para collators command"
// );
// }
// checkExists(coll.command);
// checkAccess(coll.command);
// });
}
});
await Promise.all(promises);

if (para.collators) {
for (const coll of para.collators) {
if (!coll.command) {
throw new Error(
"No command found for collators, please check your zombienet config file for collators command"
);
}
checkExists(coll.command);
checkAccess(coll.command);
}
// para.collators.forEach((coll) => {
// if (!coll.command) {
// throw new Error(
// "No command found for collators, please check your zombienet config file for para collators command"
// );
// }
// checkExists(coll.command);
// checkAccess(coll.command);
// });
}
});
await Promise.all(promises);
}
}

export function getZombieConfig(path: string) {
Expand Down
39 changes: 25 additions & 14 deletions packages/cli/src/internal/providerFactories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class ProviderFactory {
public static prepareDefaultZombie(): MoonwallProvider[] {
const MOON_PARA_WSS = process.env.MOON_PARA_WSS || "error";
const MOON_RELAY_WSS = process.env.MOON_RELAY_WSS || "error";
return ProviderFactory.prepare([
const providers = [
{
name: "w3",
type: "web3",
Expand All @@ -165,34 +165,45 @@ export class ProviderFactory {
type: "viem",
endpoints: [MOON_PARA_WSS],
},
{
name: "parachain",
type: "polkadotJs",
endpoints: [MOON_PARA_WSS],
},

{
name: "relaychain",
type: "polkadotJs",
endpoints: [MOON_RELAY_WSS],
},
]);
] satisfies ProviderConfig[];

if (MOON_PARA_WSS !== "error") {
providers.push({
name: "parachain",
type: "polkadotJs",
endpoints: [MOON_PARA_WSS],
});
}

return ProviderFactory.prepare(providers);
}

public static prepareNoEthDefaultZombie(): MoonwallProvider[] {
const MOON_PARA_WSS = process.env.MOON_PARA_WSS || "error";
const MOON_RELAY_WSS = process.env.MOON_RELAY_WSS || "error";
return ProviderFactory.prepare([
{
name: "parachain",
type: "polkadotJs",
endpoints: [MOON_PARA_WSS],
},

const providers = [
{
name: "relaychain",
type: "polkadotJs",
endpoints: [MOON_RELAY_WSS],
},
]);
] satisfies ProviderConfig[];

if (MOON_PARA_WSS !== "error") {
providers.push({
name: "parachain",
type: "polkadotJs",
endpoints: [MOON_PARA_WSS],
});
}
return ProviderFactory.prepare(providers);
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/lib/globalContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ export class MoonwallContext {
};

process.env.MOON_RELAY_WSS = network.relay[0].wsUri;
process.env.MOON_PARA_WSS = Object.values(network.paras)[0].nodes[0].wsUri;

if (Object.entries(network.paras).length > 0) {
console.dir(network.paras, { depth: null });
process.env.MOON_PARA_WSS = Object.values(network.paras)[0].nodes[0].wsUri;
}

const nodeNames = Object.keys(network.nodesByName);
process.env.MOON_ZOMBIE_DIR = `${network.tmpDir}`;
Expand Down
32 changes: 32 additions & 0 deletions test/configs/zombieNoPara.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"chain": "rococo-local",
"default_command": "tmp/polkadot",
"default_args": [
"--no-hardware-benchmarks",
"-lparachain=debug",
"--database=paritydb"
],
"nodes": [
{
"name": "alice",
"validator": true
},
{
"name": "bob",
"validator": true
}
]
},
"types": {
"Header": {
"number": "u64",
"parent_hash": "Hash",
"post_state": "Hash"
}
}
}
18 changes: 18 additions & 0 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@
}
}
},
{
"name": "zombie_noPara",
"testFileDir": ["suites/zombieNoPara"],
"timeout": 300000,
"envVars": ["DEBUG_COLORS=1"],
"reporters": ["default"],
"foundation": {
"type": "zombie",
"zombieSpec": {
"name": "zombienet",
"disableDefaultEthProviders": true,
"additionalZombieConfig": {
"silent": true
},
"configPath": "./configs/zombieNoPara.json"
}
}
},
{
"name": "para_test",
"testFileDir": ["suites/zombie"],
Expand Down
31 changes: 31 additions & 0 deletions test/suites/zombieNoPara/test_basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "@moonbeam-network/api-augment";
import { beforeAll, describeSuite, expect } from "@moonwall/cli";
import type { ApiPromise } from "@polkadot/api";

describeSuite({
id: "Z1",
title: "Zombie Test Suite",
foundationMethods: "zombie",
testCases: ({ it, context, log }) => {
let paraApi: ApiPromise;
let relayApi: ApiPromise;

beforeAll(async () => {
relayApi = context.polkadotJs("relaychain");
}, 10000);

it({
id: "T01",
title: "Check relaychain api correctly connected",
test: async () => {
const rt = relayApi.consts.system.version.specVersion.toNumber();
expect(rt).to.be.greaterThan(0);

const network = relayApi.consts.system.version.specName.toString();
expect(network).to.contain("rococo");
},
});


},
});

0 comments on commit d676ba3

Please sign in to comment.