Skip to content

Commit 8206cbb

Browse files
committed
test: fix alchemy env var not found error
Tests would complain when the Alchemy env var isn't found. The tests shouldn't even need it. This most likely came to be when the RPC URL building was changed and this test was missed. The new mocks catch that oversight.
1 parent 3b35ad3 commit 8206cbb

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

test/safe-signatures/SafeSignatureVerifier.test.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import { describe, it, expect, vi } from "vitest";
22
import Verifier from "../../src/lib/safe/signature-verification/UserUpsertSignatureVerifier.js";
33

4-
// Mock the entire getRpcUrl module
5-
vi.mock("../../src/utils/getRpcUrl.js", () => ({
6-
getRpcUrl: vi.fn().mockImplementation((chainId: number) => {
7-
if (chainId === 1) {
8-
throw new Error("Unsupported chain ID: 1");
9-
}
10-
return "mock-rpc-url";
11-
}),
12-
getEvmClient: vi.fn().mockReturnValue({
13-
verifyMessage: vi.fn().mockResolvedValue(true),
14-
}),
4+
// Fix the import paths and mock implementations
5+
vi.mock("../../src/client/evmClient.js", () => ({
6+
EvmClientFactory: {
7+
create: vi.fn().mockReturnValue({
8+
verifyMessage: vi.fn().mockResolvedValue(true),
9+
}),
10+
getAllAvailableUrls: vi
11+
.fn()
12+
.mockReturnValue(["mock-rpc-url-1", "mock-rpc-url-2"]),
13+
getPublicRpcUrl: vi.fn().mockReturnValue("mock-public-rpc-url"),
14+
},
15+
}));
16+
17+
vi.mock("../../src/lib/safe/safe-rpc-urls.js", () => ({
18+
RpcStrategyFactory: {
19+
getStrategy: vi.fn().mockReturnValue({
20+
getUrl: vi.fn().mockReturnValue("mock-rpc-url"),
21+
}),
22+
},
1523
}));
1624

1725
// Testing hashing of typed data via UserUpsertSignatureVerifier

0 commit comments

Comments
 (0)