@@ -43,6 +43,9 @@ describe('LitProvider', () => {
4343 } ,
4444 ] ;
4545
46+ const mockDomain = 'localhost' ;
47+ const mockStatement = 'Sign in with Ethereum' ;
48+
4649 beforeEach ( async ( ) => {
4750 jest . clearAllMocks ( ) ;
4851
@@ -71,7 +74,13 @@ describe('LitProvider', () => {
7174 signMessage : jest . fn ( ) . mockReturnValue ( Promise . resolve ( 'mock-signature' ) ) ,
7275 } as unknown as jest . Mocked < Signer > ;
7376
74- litProvider = new LitProvider ( mockLitClient , mockNodeConnectionConfig , mockChain ) ;
77+ litProvider = new LitProvider (
78+ mockLitClient ,
79+ mockNodeConnectionConfig ,
80+ mockChain ,
81+ mockDomain ,
82+ mockStatement ,
83+ ) ;
7584 await litProvider . initializeClient ( ) ;
7685 } ) ;
7786
@@ -189,18 +198,11 @@ describe('LitProvider', () => {
189198 derivedVia : 'mock' ,
190199 signedMessage : 'mock' ,
191200 } ;
192- const mockDomain = 'localhost' ;
193- const mockStatement = 'Sign in with Ethereum' ;
194201
195202 ( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
196203 ( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
197204
198- await litProvider . getSessionSignatures (
199- mockSigner ,
200- mockWalletAddress ,
201- mockDomain ,
202- mockStatement ,
203- ) ;
205+ await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
204206
205207 expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
206208 expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
@@ -226,10 +228,17 @@ describe('LitProvider', () => {
226228 signedMessage : 'mock' ,
227229 } ;
228230
231+ // Create new provider instance without domain and statement
232+ const providerWithoutDomainStatement = new LitProvider (
233+ mockLitClient ,
234+ mockNodeConnectionConfig ,
235+ mockChain ,
236+ ) ;
237+
229238 ( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
230239 ( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
231240
232- await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
241+ await providerWithoutDomainStatement . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
233242
234243 expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
235244 expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
@@ -253,24 +262,28 @@ describe('LitProvider', () => {
253262 derivedVia : 'mock' ,
254263 signedMessage : 'mock' ,
255264 } ;
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+ ) ;
258276
259277 ( generateAuthSig as jest . Mock ) . mockReturnValue ( Promise . resolve ( mockAuthSig ) ) ;
260278 ( createSiweMessage as jest . Mock ) . mockReturnValue ( Promise . resolve ( 'mock-siwe-message' ) ) ;
261279
262- await litProvider . getSessionSignatures (
263- mockSigner ,
264- mockWalletAddress ,
265- mockDomain ,
266- mockStatement ,
267- ) ;
280+ await providerWithCustomParams . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
268281
269282 expect ( mockLitClient . connect ) . toHaveBeenCalled ( ) ;
270283 expect ( mockLitClient . getLatestBlockhash ) . toHaveBeenCalled ( ) ;
271284 expect ( createSiweMessage ) . toHaveBeenCalledWith ( {
272- domain : mockDomain ,
273- statement : mockStatement ,
285+ domain : customDomain ,
286+ statement : customStatement ,
274287 uri : expect . any ( String ) ,
275288 expiration : expect . any ( String ) ,
276289 resources : expect . any ( Array ) ,
@@ -282,27 +295,14 @@ describe('LitProvider', () => {
282295 } ) ;
283296
284297 it ( 'should not get new signatures if they already exist' , async ( ) => {
285- const mockDomain = 'localhost' ;
286- const mockStatement = 'Sign in with Ethereum' ;
287-
288298 // Set session signatures
289- await litProvider . getSessionSignatures (
290- mockSigner ,
291- mockWalletAddress ,
292- mockDomain ,
293- mockStatement ,
294- ) ;
299+ await litProvider . getSessionSignatures ( mockSigner , mockWalletAddress ) ;
295300
296301 // Reset mocks
297302 jest . clearAllMocks ( ) ;
298303
299304 // 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 ) ;
306306
307307 expect ( mockLitClient . connect ) . not . toHaveBeenCalled ( ) ;
308308 expect ( mockLitClient . getLatestBlockhash ) . not . toHaveBeenCalled ( ) ;
0 commit comments