Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Modify `network` property in `config.json` to `test`
Sebastian Martinez committed 2 years ago
commit 18a5d40b0ae18570ab7ea56d24ce53dc8d8e2508
parent 6a1137a0242a06db0269618526d13689364d5753
2 files changed +36 -1
modified tests/support/heartwood-version
@@ -1 +1 @@
-
b456d3a401abf5314598cbede49c4fb2864bdf6f
+
15b50ce6a544bdb7d22e124d486eeb933456f87e
modified tests/support/peerManager.ts
@@ -14,6 +14,7 @@ import { execa } from "execa";
import * as Process from "./process.js";
import { randomTag } from "@tests/support/support.js";
import { sleep } from "@app/lib/sleep.js";
+
import { array, boolean, literal, number, object, string, union, z } from "zod";

export type RefsUpdate =
  | { updated: { name: string; old: string; new: string } }
@@ -105,6 +106,29 @@ export async function createPeerManager(createParams: {
  };
}

+
export const NodeConfigSchema = object({
+
  node: object({
+
    alias: string(),
+
    peers: union([
+
      object({ type: literal("static") }),
+
      object({ type: literal("dynamic"), target: number() }),
+
    ]),
+
    connect: array(string()),
+
    externalAddresses: array(string()),
+
    network: union([literal("main"), literal("test")]),
+
    relay: boolean(),
+
    limits: object({
+
      routingMaxSize: number(),
+
      routingMaxAge: number(),
+
      fetchConcurrency: number(),
+
    }),
+
    policy: union([literal("track"), literal("block")]),
+
    scope: union([literal("trusted"), literal("all")]),
+
  }),
+
});
+

+
export interface NodeConfig extends z.infer<typeof NodeConfigSchema> {}
+

export class RadiclePeer {
  public checkoutPath: string;
  public nodeId: string;
@@ -173,6 +197,17 @@ export class RadiclePeer {
    };

    await execa("rad", ["auth", "--alias", name], { env });
+
    const config = await Fs.readFile(
+
      Path.join(radHome, "config.json"),
+
      "utf-8",
+
    );
+
    const parsedConfig = NodeConfigSchema.parse(JSON.parse(config));
+
    parsedConfig.node.network = "test";
+
    await Fs.writeFile(
+
      Path.join(radHome, "config.json"),
+
      JSON.stringify(parsedConfig),
+
      "utf-8",
+
    );
    const { stdout: nodeId } = await execa("rad", ["self", "--nid"], { env });

    return new RadiclePeer({