Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: plugin-story #1030

Merged
merged 22 commits into from
Dec 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
add basic test for plugin-story
jacob-tucker committed Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2e72e61aaf739defefc65a642960da966ee17145
3 changes: 2 additions & 1 deletion packages/plugin-story/package.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch"
"dev": "tsup --format esm --dts --watch",
"test": "vitest run"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
63 changes: 63 additions & 0 deletions packages/plugin-story/src/tests/wallet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { describe, it, expect, beforeEach, vi, afterEach } from "vitest";
import { WalletProvider } from "../providers/wallet.ts";
import { defaultCharacter } from "@ai16z/eliza";

// Mock NodeCache
vi.mock("node-cache", () => {
return {
default: vi.fn().mockImplementation(() => ({
set: vi.fn(),
get: vi.fn().mockReturnValue(null),
})),
};
});

// Mock path module
vi.mock("path", async () => {
const actual = await vi.importActual("path");
return {
...actual,
join: vi.fn().mockImplementation((...args) => args.join("/")),
};
});

// Mock the ICacheManager
const mockCacheManager = {
get: vi.fn().mockResolvedValue(null),
set: vi.fn(),
delete: vi.fn(),
};

describe("WalletProvider", () => {
let walletProvider;
let mockedRuntime;

beforeEach(() => {
vi.clearAllMocks();
mockCacheManager.get.mockResolvedValue(null);

mockedRuntime = {
character: defaultCharacter,
getSetting: vi.fn().mockImplementation((key: string) => {
// this is a testnet private key
if (key === "STORY_PRIVATE_KEY")
return "0x1ad065323caa081ab78d6f4fd2b52181e09cf29a4e60bd7519997b2d03fa44f3";
return undefined;
}),
};

// Create new instance of WalletProvider with mocked dependencies
walletProvider = new WalletProvider(mockedRuntime);
});

afterEach(() => {
vi.clearAllTimers();
});

describe("Wallet Integration", () => {
it("should check wallet address", async () => {
const address = await walletProvider.getAddress();
expect(address).toEqual(walletProvider.address);
});
});
});