@@ -3,11 +3,14 @@ import { encryptWithCipher } from "../crypto";
33import { spiltKeyIntoShards } from "../key-shard" ;
44
55// Mock external wallet SDKs
6+ const mockCardanoWalletInstance = {
7+ getUsedAddressesBech32 : jest . fn ( ) . mockResolvedValue ( [ "addr_test1..." ] ) ,
8+ } ;
9+
610jest . mock ( "@meshsdk/wallet" , ( ) => ( {
7- MeshWallet : jest . fn ( ) . mockImplementation ( ( ) => ( {
8- init : jest . fn ( ) . mockResolvedValue ( undefined ) ,
9- getUsedAddresses : jest . fn ( ) . mockResolvedValue ( [ "addr_test1..." ] ) ,
10- } ) ) ,
11+ MeshCardanoHeadlessWallet : {
12+ fromMnemonic : jest . fn ( ) . mockResolvedValue ( mockCardanoWalletInstance ) ,
13+ } ,
1114} ) ) ;
1215
1316jest . mock ( "@meshsdk/bitcoin" , ( ) => ( {
@@ -28,7 +31,7 @@ jest.mock("@buildonspark/spark-sdk", () => ({
2831
2932// Import after mocks
3033import { clientDeriveWallet } from "./derive-wallet" ;
31- import { MeshWallet } from "@meshsdk/wallet" ;
34+ import { MeshCardanoHeadlessWallet } from "@meshsdk/wallet" ;
3235import { EmbeddedWallet } from "@meshsdk/bitcoin" ;
3336import { SparkWallet } from "@buildonspark/spark-sdk" ;
3437
@@ -122,7 +125,7 @@ describe("clientDeriveWallet", () => {
122125 expect ( EmbeddedWallet ) . toHaveBeenCalledWith (
123126 expect . objectContaining ( { network : "Testnet" } ) ,
124127 ) ;
125- expect ( MeshWallet ) . toHaveBeenCalledWith (
128+ expect ( MeshCardanoHeadlessWallet . fromMnemonic ) . toHaveBeenCalledWith (
126129 expect . objectContaining ( { networkId : 0 } ) ,
127130 ) ;
128131 expect ( SparkWallet . initialize ) . toHaveBeenCalledWith (
@@ -146,7 +149,7 @@ describe("clientDeriveWallet", () => {
146149 expect ( EmbeddedWallet ) . toHaveBeenCalledWith (
147150 expect . objectContaining ( { network : "Mainnet" } ) ,
148151 ) ;
149- expect ( MeshWallet ) . toHaveBeenCalledWith (
152+ expect ( MeshCardanoHeadlessWallet . fromMnemonic ) . toHaveBeenCalledWith (
150153 expect . objectContaining ( { networkId : 1 } ) ,
151154 ) ;
152155 expect ( SparkWallet . initialize ) . toHaveBeenCalledWith (
@@ -241,24 +244,6 @@ describe("clientDeriveWallet", () => {
241244 expect ( result . key ) . toBe ( testMnemonic ) ;
242245 } ) ;
243246
244- it ( "initializes cardano wallet" , async ( ) => {
245- const shards = await spiltKeyIntoShards ( testMnemonic ) ;
246- const deviceKey = await deriveKeyFromPassword ( "device-password" ) ;
247-
248- const encryptedDeviceShard = await encryptWithCipher ( {
249- data : shards [ 0 ] ! ,
250- key : deviceKey ,
251- } ) ;
252-
253- const result = await clientDeriveWallet (
254- encryptedDeviceShard ,
255- deviceKey ,
256- shards [ 1 ] ! ,
257- 0 ,
258- ) ;
259-
260- expect ( result . cardanoWallet . init ) . toHaveBeenCalled ( ) ;
261- } ) ;
262247} ) ;
263248
264249describe ( "clientDeriveWallet with 24-word mnemonic" , ( ) => {
0 commit comments