@aixyz/cli 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,156 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { CHAIN_ID, getIdentityRegistryAddress } from "@aixyz/erc-8004";
3
- import { setAgentUri, validateAgentId } from "./set-agent-uri";
4
-
5
- describe("set-agent-uri command chain configuration", () => {
6
- test("sepolia chain ID is correct", () => {
7
- expect(CHAIN_ID.SEPOLIA).toStrictEqual(11155111);
8
- });
9
-
10
- test("base-sepolia chain ID is correct", () => {
11
- expect(CHAIN_ID.BASE_SEPOLIA).toStrictEqual(84532);
12
- });
13
-
14
- test("identity registry address is returned for sepolia", () => {
15
- const address = getIdentityRegistryAddress(CHAIN_ID.SEPOLIA);
16
- expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/);
17
- });
18
-
19
- test("identity registry address is returned for base-sepolia", () => {
20
- const address = getIdentityRegistryAddress(CHAIN_ID.BASE_SEPOLIA);
21
- expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/);
22
- });
23
-
24
- test("throws for unsupported chain ID", () => {
25
- expect(() => getIdentityRegistryAddress(999999)).toThrow("Unsupported chain ID");
26
- });
27
- });
28
-
29
- describe("validateAgentId", () => {
30
- test("accepts 0", () => {
31
- expect(() => validateAgentId("0")).not.toThrow();
32
- });
33
-
34
- test("accepts positive integer", () => {
35
- expect(() => validateAgentId("42")).not.toThrow();
36
- });
37
-
38
- test("accepts large integer", () => {
39
- expect(() => validateAgentId("999999999")).not.toThrow();
40
- });
41
-
42
- test("rejects empty string", () => {
43
- expect(() => validateAgentId("")).toThrow("Invalid agent ID");
44
- });
45
-
46
- test("rejects whitespace-only string", () => {
47
- expect(() => validateAgentId(" ")).toThrow("Invalid agent ID");
48
- });
49
-
50
- test("accepts leading zeros", () => {
51
- expect(() => validateAgentId("007")).not.toThrow();
52
- });
53
-
54
- test("accepts single leading zero before digits", () => {
55
- expect(() => validateAgentId("042")).not.toThrow();
56
- });
57
-
58
- test("rejects negative number", () => {
59
- expect(() => validateAgentId("-1")).toThrow("Invalid agent ID");
60
- });
61
-
62
- test("rejects float", () => {
63
- expect(() => validateAgentId("1.5")).toThrow("Invalid agent ID");
64
- });
65
-
66
- test("rejects non-numeric string", () => {
67
- expect(() => validateAgentId("abc")).toThrow("Invalid agent ID");
68
- });
69
-
70
- test("rejects mixed string", () => {
71
- expect(() => validateAgentId("12abc")).toThrow("Invalid agent ID");
72
- });
73
-
74
- test("rejects Infinity", () => {
75
- expect(() => validateAgentId("Infinity")).toThrow("Invalid agent ID");
76
- });
77
-
78
- test("rejects NaN", () => {
79
- expect(() => validateAgentId("NaN")).toThrow("Invalid agent ID");
80
- });
81
- });
82
-
83
- describe("set-agent-uri command validation", () => {
84
- test("localhost requires --registry flag", async () => {
85
- await expect(
86
- setAgentUri({ agentId: "1", uri: "https://example.com/agent.json", chain: "localhost" }),
87
- ).rejects.toThrow("--registry is required for localhost");
88
- });
89
-
90
- test("rejects unsupported chain", async () => {
91
- await expect(
92
- setAgentUri({ agentId: "1", uri: "https://example.com/agent.json", chain: "fakenet" }),
93
- ).rejects.toThrow("Unsupported chain: fakenet");
94
- });
95
-
96
- test("rejects invalid registry address", async () => {
97
- await expect(
98
- setAgentUri({
99
- agentId: "1",
100
- uri: "https://example.com/agent.json",
101
- chain: "localhost",
102
- registry: "not-an-address",
103
- }),
104
- ).rejects.toThrow("Invalid registry address: not-an-address");
105
- });
106
-
107
- test("rejects --browser with --rpc-url", async () => {
108
- await expect(
109
- setAgentUri({
110
- agentId: "0",
111
- uri: "https://example.com/agent.json",
112
- chain: "sepolia",
113
- browser: true,
114
- rpcUrl: "http://localhost:8545",
115
- }),
116
- ).rejects.toThrow("--rpc-url cannot be used with browser wallet");
117
- });
118
-
119
- test("dry-run completes without wallet interaction when --broadcast is not set", async () => {
120
- await expect(
121
- setAgentUri({ agentId: "1", uri: "https://example.com/agent.json", chain: "sepolia" }),
122
- ).resolves.toBeUndefined();
123
- });
124
-
125
- test("rejects invalid agent ID (negative)", async () => {
126
- await expect(
127
- setAgentUri({ agentId: "-1", uri: "https://example.com/agent.json", chain: "sepolia" }),
128
- ).rejects.toThrow("Invalid agent ID");
129
- });
130
-
131
- test("rejects invalid agent ID (non-integer)", async () => {
132
- await expect(
133
- setAgentUri({ agentId: "abc", uri: "https://example.com/agent.json", chain: "sepolia" }),
134
- ).rejects.toThrow("Invalid agent ID");
135
- });
136
-
137
- test("rejects invalid agent ID (float)", async () => {
138
- await expect(
139
- setAgentUri({ agentId: "1.5", uri: "https://example.com/agent.json", chain: "sepolia" }),
140
- ).rejects.toThrow("Invalid agent ID");
141
- });
142
-
143
- test("accepts agent ID 0 as valid", async () => {
144
- // Agent ID 0 passes validation — triggers a later error (browser+rpc-url conflict)
145
- // proving the agent ID check did not reject it
146
- await expect(
147
- setAgentUri({
148
- agentId: "0",
149
- uri: "https://example.com/agent.json",
150
- chain: "sepolia",
151
- browser: true,
152
- rpcUrl: "http://localhost:8545",
153
- }),
154
- ).rejects.toThrow("--rpc-url cannot be used with browser wallet");
155
- });
156
- });