Skip to content

Commit ca1a2c5

Browse files
committed
fix(evm-wallet-experiment): Docker E2E vs fetch mock; OpenClaw daemon exec tests
Default Vitest inherits root setupFiles including vitest-fetch-mock, which stubs global fetch. Docker E2E calls Anvil on localhost:8545 with real fetch; under the mock, responses were empty and evmRpc failed parsing JSON. Exclude test/e2e/docker from the main evm-wallet Vitest project and run those tests with yarn test:e2e:docker (vitest.config.docker.ts uses no fetch mock). Align OpenClaw wallet plugin unit tests with the plugin's ocap daemon exec queueMessage argv layout (JSON blob for kref, method, args). Refresh yarn.lock workspace metadata for @ocap/kernel-agents on this package. Made-with: Cursor
1 parent a45f63a commit ca1a2c5

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

packages/evm-wallet-experiment/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
"@metamask/eslint-config-nodejs": "^15.0.0",
8989
"@metamask/eslint-config-typescript": "^15.0.0",
9090
"@metamask/kernel-cli": "workspace:^",
91-
"@ocap/kernel-agents": "workspace:^",
9291
"@metamask/kernel-node-runtime": "workspace:^",
9392
"@metamask/kernel-shims": "workspace:^",
9493
"@metamask/kernel-store": "workspace:^",
94+
"@ocap/kernel-agents": "workspace:^",
9595
"@ocap/repo-tools": "workspace:^",
9696
"@ts-bridge/cli": "^0.6.3",
9797
"@ts-bridge/shims": "^0.1.1",

packages/evm-wallet-experiment/test/openclaw-plugin.test.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type MockReadable = EventEmitter & {
2828
};
2929

3030
/**
31-
* Encode a value as the JSON output of `ocap daemon queueMessage`.
31+
* Encode a value as the JSON output of `ocap daemon exec queueMessage` (decoded payload).
3232
*
3333
* The CLI auto-decodes CapData via prettifySmallcaps, so the output
3434
* is plain JSON (not CapData-wrapped).
@@ -216,12 +216,14 @@ describe('openclaw wallet plugin', () => {
216216
);
217217
expect(result.content[0]?.text).toContain('UserOp hash: 0xtxhash');
218218

219-
// New CLI format: ['daemon', 'queueMessage', kref, method, argsJson]
219+
// CLI format: ['daemon', 'exec', 'queueMessage', JSON.stringify([kref, method, args])]
220220
const sendCallArgs = mockSpawn.mock.calls[1]?.[1] as string[];
221-
expect(sendCallArgs[1]).toBe('queueMessage');
222-
expect(sendCallArgs[2]).toBe('ko4');
223-
expect(sendCallArgs[3]).toBe('sendTransaction');
224-
const sendArgs = JSON.parse(sendCallArgs[4] ?? 'null') as unknown[];
221+
expect(sendCallArgs[1]).toBe('exec');
222+
expect(sendCallArgs[2]).toBe('queueMessage');
223+
const queueParams = JSON.parse(sendCallArgs[3] ?? 'null') as unknown[];
224+
expect(queueParams[0]).toBe('ko4');
225+
expect(queueParams[1]).toBe('sendTransaction');
226+
const sendArgs = queueParams[2] as unknown[];
225227

226228
// 0.08 ETH = 80000000000000000 wei = 0x11c37937e080000
227229
expect(sendArgs).toStrictEqual([
@@ -379,9 +381,11 @@ describe('openclaw wallet plugin', () => {
379381
);
380382

381383
// Verify the sendErc20Transfer daemon call
382-
// New CLI format: ['daemon', 'queueMessage', kref, method, argsJson]
383384
const sendCallArgs = mockSpawn.mock.calls[1]?.[1] as string[];
384-
expect(sendCallArgs[3]).toBe('sendErc20Transfer');
385+
expect(sendCallArgs[1]).toBe('exec');
386+
expect(sendCallArgs[2]).toBe('queueMessage');
387+
const queueParams = JSON.parse(sendCallArgs[3] ?? 'null') as unknown[];
388+
expect(queueParams[1]).toBe('sendErc20Transfer');
385389
});
386390

387391
it('waits for a delayed UserOp receipt before showing tx hash', async () => {
@@ -573,9 +577,13 @@ describe('openclaw wallet plugin', () => {
573577
expect(result.content[0]?.text).toContain('USDC');
574578
expect(result.content[0]?.text).toContain('raw: 1000000');
575579
// Verify the resolved address was used for daemon calls
576-
// New CLI format: ['daemon', 'queueMessage', kref, method, argsJson]
577580
const balanceCallArgs = mockSpawn.mock.calls[2]?.[1] as string[];
578-
const balanceArgs = JSON.parse(balanceCallArgs[4] ?? 'null') as unknown[];
581+
expect(balanceCallArgs[1]).toBe('exec');
582+
expect(balanceCallArgs[2]).toBe('queueMessage');
583+
const balanceQueueParams = JSON.parse(
584+
balanceCallArgs[3] ?? 'null',
585+
) as unknown[];
586+
const balanceArgs = balanceQueueParams[2] as unknown[];
579587
expect((balanceArgs[0] as Record<string, unknown>).token).toBe(
580588
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
581589
);

packages/evm-wallet-experiment/vitest.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export default defineConfig((args) => {
1616
import.meta.resolve('@ocap/repo-tools/test-utils/mock-endoify'),
1717
),
1818
],
19-
exclude: ['test/integration/**'],
19+
exclude: [
20+
'test/integration/**',
21+
// Real `fetch` to localhost (Anvil); incompatible with root vitest-fetch-mock.
22+
// Run: yarn test:e2e:docker
23+
'test/e2e/docker/**',
24+
],
2025
},
2126
}),
2227
);

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,6 +3772,7 @@ __metadata:
37723772
"@metamask/superstruct": "npm:^3.2.1"
37733773
"@noble/ciphers": "npm:^1.3.0"
37743774
"@noble/hashes": "npm:^1.8.0"
3775+
"@ocap/kernel-agents": "workspace:^"
37753776
"@ocap/repo-tools": "workspace:^"
37763777
"@ts-bridge/cli": "npm:^0.6.3"
37773778
"@ts-bridge/shims": "npm:^0.1.1"

0 commit comments

Comments
 (0)