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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ EXAMPLES:
genlayer update ollama --model deepseek-r1 --remove
```

#### Validator Management
#### Localnet Validator Management

Manage validator operations.
Manage localnet validator operations.

```bash
USAGE:
genlayer validators <command> [options]
genlayer localnet validators <command> [options]

COMMANDS:
get [--address <validatorAddress>] Retrieve details of a specific validator or all validators
Expand Down Expand Up @@ -253,16 +253,16 @@ OPTIONS (create):
--model <model> Specify the model for the validator

EXAMPLES:
genlayer validators get
genlayer validators get --address 0x123456789abcdef
genlayer localnet validators get
genlayer localnet validators get --address 0x123456789abcdef

genlayer validators count
genlayer validators delete --address 0x123456789abcdef
genlayer validators update 0x123456789abcdef --stake 100 --provider openai --model gpt-4
genlayer localnet validators count
genlayer localnet validators delete --address 0x123456789abcdef
genlayer localnet validators update 0x123456789abcdef --stake 100 --provider openai --model gpt-4

genlayer validators create
genlayer validators create --stake 50 --provider openai --model gpt-4
genlayer validators create-random --count 3 --providers openai --models gpt-4 gpt-4o
genlayer localnet validators create
genlayer localnet validators create --stake 50 --provider openai --model gpt-4
genlayer localnet validators create-random --count 3 --providers openai --models gpt-4 gpt-4o
```

### Running the CLI from the repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { ValidatorsAction } from "./validators";
export function initializeValidatorCommands(program: Command) {
const validatorsAction = new ValidatorsAction();

const validatorsCommand = program
const localnetCommand = program
.command("localnet")
.description("Manage localnet operations");

const validatorsCommand = localnetCommand
.command("validators")
.description("Manage validator operations");
.description("Manage localnet validators operations");

validatorsCommand
.command("get")
Expand Down Expand Up @@ -77,7 +81,7 @@ export function initializeValidatorCommands(program: Command) {
.option("--stake <stake>", "Stake amount for the validator (default: 1)", "1")
.option(
"--config <config>",
'Optional JSON configuration for the validator (e.g., \'{"max_tokens": 500, "temperature": 0.75}\')'
`Optional JSON configuration for the validator (e.g., '{"max_tokens": 500, "temperature": 0.75}')`
)
.option("--provider <provider>", "Specify the provider for the validator")
.option("--model <model>", "Specify the model for the validator")
Expand All @@ -92,3 +96,5 @@ export function initializeValidatorCommands(program: Command) {

return program;
}


Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,5 @@ export class ValidatorsAction extends BaseAction {
}
}
}


2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {initializeGeneralCommands} from "../src/commands/general";
import {initializeKeygenCommands} from "../src/commands/keygen";
import {initializeContractsCommands} from "../src/commands/contracts";
import {initializeConfigCommands} from "../src/commands/config";
import {initializeValidatorCommands} from "../src/commands/validators";
import {initializeValidatorCommands} from "../src/commands/localnet";
import {initializeUpdateCommands} from "../src/commands/update";
import {initializeScaffoldCommands} from "../src/commands/scaffold";
import {initializeNetworkCommands} from "../src/commands/network";
Expand Down
2 changes: 1 addition & 1 deletion tests/actions/validators.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test, vi, beforeEach, afterEach, expect } from "vitest";
import { ValidatorsAction } from "../../src/commands/validators/validators";
import { ValidatorsAction } from "../../src/commands/localnet/validators";
import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
import inquirer from "inquirer";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Command } from "commander";
import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
import { initializeValidatorCommands } from "../../src/commands/validators";
import { ValidatorsAction } from "../../src/commands/validators/validators";
import { initializeValidatorCommands } from "../../src/commands/localnet";
import { ValidatorsAction } from "../../src/commands/localnet/validators";

vi.mock("../../src/commands/validators/validators");
vi.mock("../../src/commands/localnet/validators");

describe("validators command", () => {
describe("localnet validator command", () => {
let program: Command;

beforeEach(() => {
Expand All @@ -18,35 +18,35 @@ describe("validators command", () => {
});

test("ValidatorsAction.getValidator is called with address option", async () => {
program.parse(["node", "test", "validators", "get", "--address", "mocked_address"]);
program.parse(["node", "test", "localnet", "validators", "get", "--address", "mocked_address"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.getValidator).toHaveBeenCalledWith({
address: "mocked_address",
});
});

test("ValidatorsAction.getValidator is called without address option", async () => {
program.parse(["node", "test", "validators", "get"]);
program.parse(["node", "test", "localnet", "validators", "get"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.getValidator).toHaveBeenCalledWith({});
});

test("ValidatorsAction.deleteValidator is called with address option", async () => {
program.parse(["node", "test", "validators", "delete", "--address", "mocked_address"]);
program.parse(["node", "test", "localnet", "validators", "delete", "--address", "mocked_address"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.deleteValidator).toHaveBeenCalledWith({
address: "mocked_address",
});
});

test("ValidatorsAction.deleteValidator is called without address option", async () => {
program.parse(["node", "test", "validators", "delete"]);
program.parse(["node", "test", "localnet", "validators", "delete"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.deleteValidator).toHaveBeenCalledWith({});
});

test("ValidatorsAction.countValidators is called", async () => {
program.parse(["node", "test", "validators", "count"]);
program.parse(["node", "test", "localnet", "validators", "count"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.countValidators).toHaveBeenCalled();
});
Expand All @@ -55,6 +55,7 @@ describe("validators command", () => {
program.parse([
"node",
"test",
"localnet",
"validators",
"update",
"mocked_address",
Expand All @@ -81,6 +82,7 @@ describe("validators command", () => {
program.parse([
"node",
"test",
"localnet",
"validators",
"create-random",
"--count",
Expand All @@ -98,7 +100,7 @@ describe("validators command", () => {
});

test("ValidatorsAction.createValidator is called with default stake", async () => {
program.parse(["node", "test", "validators", "create"]);
program.parse(["node", "test", "localnet", "validators", "create"]);
expect(ValidatorsAction).toHaveBeenCalledTimes(1);
expect(ValidatorsAction.prototype.createValidator).toHaveBeenCalledWith({
stake: "1",
Expand All @@ -110,6 +112,7 @@ describe("validators command", () => {
program.parse([
"node",
"test",
"localnet",
"validators",
"create",
"--stake",
Expand All @@ -123,5 +126,6 @@ describe("validators command", () => {
config: '{"temperature":0.8}',
});
});

});


2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vi.mock("../src/commands/config", () => ({
initializeConfigCommands: vi.fn(),
}));

vi.mock("../src/commands/validators", () => ({
vi.mock("../src/commands/localnet", () => ({
initializeValidatorCommands: vi.fn(),
}));

Expand Down