Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(walletApi): cover recovery phrase generation and validation

Steven Enamakel7dae8aa83b8d
diff --git a/app/src/services/walletApi.test.ts b/app/src/services/walletApi.test.ts
index 626de24576..6ecad3cab0 100644
--- a/app/src/services/walletApi.test.ts
+++ b/app/src/services/walletApi.test.ts
@@ -32,6 +32,32 @@ describe('walletApi', () => {
expect(result.configured).toBe(true);
});
+ it('generateRecoveryPhrase requests the module-owned 12-word phrase', async () => {
+ mockCallCoreRpc.mockResolvedValueOnce({ result: { phrase: 'word1 ... word12', wordCount: 12 } });
+
+ const { generateRecoveryPhrase } = await import('./walletApi');
+ const result = await generateRecoveryPhrase();
+
+ expect(mockCallCoreRpc).toHaveBeenCalledWith({
+ method: 'openhuman.wallet_generate_mnemonic',
+ params: { wordCount: 12 },
+ });
+ expect(result).toEqual({ phrase: 'word1 ... word12', wordCount: 12 });
+ });
+
+ it('validateRecoveryPhrase asks the module to validate an imported phrase', async () => {
+ mockCallCoreRpc.mockResolvedValueOnce({ result: { valid: false } });
+
+ const { validateRecoveryPhrase } = await import('./walletApi');
+ const result = await validateRecoveryPhrase('abandon abandon');
+
+ expect(mockCallCoreRpc).toHaveBeenCalledWith({
+ method: 'openhuman.wallet_validate_mnemonic',
+ params: { phrase: 'abandon abandon' },
+ });
+ expect(result).toBe(false);
+ });
+
it('setupLocalWallet calls the wallet setup RPC with params', async () => {
const payload = {
consentGranted: true,