@@ -8,7 +8,8 @@ describe('LitCore', () => {
88 describe ( 'getLatestBlockhash' , ( ) => {
99 let originalFetch : typeof fetch ;
1010 let originalDateNow : typeof Date . now ;
11- const mockBlockhashUrl = 'https://block-indexer-url.com/get_most_recent_valid_block' ;
11+ const mockBlockhashUrl =
12+ 'https://block-indexer-url.com/get_most_recent_valid_block' ;
1213
1314 beforeEach ( ( ) => {
1415 core = new LitCore ( {
@@ -51,7 +52,12 @@ describe('LitCore', () => {
5152 const blockNumber = 12345 ;
5253 global . fetch = jest . fn ( ) . mockResolvedValue ( {
5354 ok : true ,
54- json : ( ) => Promise . resolve ( { blockhash : mockBlockhash , timestamp : currentTime , blockNumber } ) ,
55+ json : ( ) =>
56+ Promise . resolve ( {
57+ blockhash : mockBlockhash ,
58+ timestamp : currentTime ,
59+ blockNumber,
60+ } ) ,
5561 } ) ;
5662 Date . now = jest . fn ( ) . mockReturnValue ( currentTime ) ;
5763
@@ -73,7 +79,9 @@ describe('LitCore', () => {
7379 core [ '_getProviderWithFallback' ] = jest . fn ( ( ) => Promise . resolve ( null ) ) ;
7480
7581 // Execute & Assert
76- await expect ( core . getLatestBlockhash ( ) ) . rejects . toThrow ( InvalidEthBlockhash ) ;
82+ await expect ( core . getLatestBlockhash ( ) ) . rejects . toThrow (
83+ InvalidEthBlockhash
84+ ) ;
7785 } ) ;
7886
7987 it ( 'should handle fetch failure and use fallback RPC' , async ( ) => {
@@ -87,7 +95,7 @@ describe('LitCore', () => {
8795 getBlock : jest . fn ( ) . mockResolvedValue ( {
8896 hash : mockBlockhash ,
8997 number : 12345 ,
90- timestamp : currentTime
98+ timestamp : currentTime ,
9199 } ) ,
92100 } ;
93101 jest . spyOn ( core as any , '_getProviderWithFallback' ) . mockResolvedValue ( {
@@ -110,17 +118,18 @@ describe('LitCore', () => {
110118 Date . now = jest . fn ( ) . mockReturnValue ( currentTime ) ;
111119 global . fetch = jest . fn ( ) . mockResolvedValue ( {
112120 ok : true ,
113- json : ( ) => Promise . resolve ( {
114- blockhash : null ,
115- blockNumber : null
116- } ) ,
121+ json : ( ) =>
122+ Promise . resolve ( {
123+ blockhash : null ,
124+ blockNumber : null ,
125+ } ) ,
117126 } ) ;
118127 const mockProvider = {
119128 getBlockNumber : jest . fn ( ) . mockResolvedValue ( 12345 ) ,
120129 getBlock : jest . fn ( ) . mockResolvedValue ( {
121130 hash : mockBlockhash ,
122131 number : 12345 ,
123- timestamp : currentTime
132+ timestamp : currentTime ,
124133 } ) ,
125134 } ;
126135 jest . spyOn ( core as any , '_getProviderWithFallback' ) . mockResolvedValue ( {
@@ -141,11 +150,14 @@ describe('LitCore', () => {
141150 const currentTime = 1000000 ;
142151 Date . now = jest . fn ( ) . mockReturnValue ( currentTime ) ;
143152
144- global . fetch = jest . fn ( ) . mockImplementation ( ( ) =>
145- new Promise ( ( _ , reject ) =>
146- setTimeout ( ( ) => reject ( new Error ( 'Network timeout' ) ) , 1000 )
147- )
148- ) ;
153+ global . fetch = jest
154+ . fn ( )
155+ . mockImplementation (
156+ ( ) =>
157+ new Promise ( ( _ , reject ) =>
158+ setTimeout ( ( ) => reject ( new Error ( 'Network timeout' ) ) , 1000 )
159+ )
160+ ) ;
149161
150162 const mockProvider = {
151163 getBlockNumber : jest . fn ( ) . mockResolvedValue ( 12345 ) ,
@@ -162,5 +174,4 @@ describe('LitCore', () => {
162174 ) ;
163175 } ) ;
164176 } ) ;
165-
166177} ) ;
0 commit comments