@@ -43,6 +43,9 @@ describe('LitProvider', () => {
43
43
} ,
44
44
] ;
45
45
46
+ const mockDomain = 'localhost' ;
47
+ const mockStatement = 'Sign in with Ethereum' ;
48
+
46
49
beforeEach ( async ( ) => {
47
50
jest . clearAllMocks ( ) ;
48
51
@@ -71,7 +74,13 @@ describe('LitProvider', () => {
71
74
signMessage : jest . fn ( ) . mockReturnValue ( Promise . resolve ( 'mock-signature' ) ) ,
72
75
} as unknown as jest . Mocked < Signer > ;
73
76
74
- litProvider = new LitProvider ( mockLitClient , mockNodeConnectionConfig , mockChain ) ;
77
+ litProvider = new LitProvider (
78
+ mockLitClient ,
79
+ mockNodeConnectionConfig ,
80
+ mockChain ,
81
+ mockDomain ,
82
+ mockStatement ,
83
+ ) ;
75
84
await litProvider . initializeClient ( ) ;
76
85
} ) ;
77
86
@@ -189,18 +198,11 @@ describe('LitProvider', () => {
189
198
derivedVia : 'mock' ,
190
199
signedMessage : 'mock' ,
191
200
} ;
192
- const mockDomain = 'localhost' ;
193
- const mockStatement = 'Sign in with Ethereum' ;
194
201
195
202
( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
196
203
( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
197
204
198
- await litProvider . getSessionSignatures (
199
- mockSigner ,
200
- mockWalletAddress ,
201
- mockDomain ,
202
- mockStatement ,
203
- ) ;
205
+ await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
204
206
205
207
expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
206
208
expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
@@ -226,10 +228,17 @@ describe('LitProvider', () => {
226
228
signedMessage : 'mock' ,
227
229
} ;
228
230
231
+ // Create new provider instance without domain and statement
232
+ const providerWithoutDomainStatement = new LitProvider (
233
+ mockLitClient ,
234
+ mockNodeConnectionConfig ,
235
+ mockChain ,
236
+ ) ;
237
+
229
238
( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
230
239
( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
231
240
232
- await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
241
+ await providerWithoutDomainStatement . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
233
242
234
243
expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
235
244
expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
@@ -253,24 +262,28 @@ describe('LitProvider', () => {
253
262
derivedVia : 'mock' ,
254
263
signedMessage : 'mock' ,
255
264
} ;
256
- const mockDomain = 'custom.domain' ;
257
- const mockStatement = 'Custom statement for signing' ;
265
+ const customDomain = 'custom.domain' ;
266
+ const customStatement = 'Custom statement for signing' ;
267
+
268
+ // Create new provider instance with custom domain and statement
269
+ const providerWithCustomParams = new LitProvider (
270
+ mockLitClient ,
271
+ mockNodeConnectionConfig ,
272
+ mockChain ,
273
+ customDomain ,
274
+ customStatement ,
275
+ ) ;
258
276
259
277
( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
260
278
( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
261
279
262
- await litProvider . getSessionSignatures (
263
- mockSigner ,
264
- mockWalletAddress ,
265
- mockDomain ,
266
- mockStatement ,
267
- ) ;
280
+ await providerWithCustomParams . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
268
281
269
282
expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
270
283
expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
271
284
expect ( createSiweMessage ) . toHaveBeenCalledWith ( {
272
- domain : mockDomain ,
273
- statement : mockStatement ,
285
+ domain : customDomain ,
286
+ statement : customStatement ,
274
287
uri : expect . any ( String ) ,
275
288
expiration : expect . any ( String ) ,
276
289
resources : expect . any ( Array ) ,
@@ -282,27 +295,14 @@ describe('LitProvider', () => {
282
295
} ) ;
283
296
284
297
it ( 'should not get new signatures if they already exist' , async ( ) => {
285
- const mockDomain = 'localhost' ;
286
- const mockStatement = 'Sign in with Ethereum' ;
287
-
288
298
// Set session signatures
289
- await litProvider . getSessionSignatures (
290
- mockSigner ,
291
- mockWalletAddress ,
292
- mockDomain ,
293
- mockStatement ,
294
- ) ;
299
+ await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
295
300
296
301
// Reset mocks
297
302
jest . clearAllMocks ( ) ;
298
303
299
304
// Call again, should not call Lit SDK methods
300
- await litProvider . getSessionSignatures (
301
- mockSigner ,
302
- mockWalletAddress ,
303
- mockDomain ,
304
- mockStatement ,
305
- ) ;
305
+ await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
306
306
307
307
expect ( mockLitClient . connect ) . not . toHaveBeenCalled ( ) ;
308
308
expect ( mockLitClient . getLatestBlockhash ) . not . toHaveBeenCalled ( ) ;
0 commit comments