@@ -177,114 +177,3 @@ describe('all', () => {
177177 } ) ;
178178 } ) ;
179179} ) ;
180-
181- describe ( 'rpc override' , ( ) => {
182- const TEST_RPC = process . env . LIT_YELLOWSTONE_PRIVATE_RPC_URL ;
183- // const TEST_RPC = 'https://yellowstone-override.example';
184-
185- // beforeAll(() => {
186- // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = TEST_RPC;
187- // });
188-
189- // afterAll(() => {
190- // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = ORIGINAL_RPC;
191- // });
192-
193- it ( 'applies env rpc override to module and client' , async ( ) => {
194- const networks = await import ( '@lit-protocol/networks' ) ;
195-
196- // choose module by NETWORK env (same way init.ts does)
197- const network = process . env . NETWORK || 'naga-dev' ;
198- const importNameMap : Record < string , string > = {
199- 'naga-dev' : 'nagaDev' ,
200- 'naga-test' : 'nagaTest' ,
201- 'naga-local' : 'nagaLocal' ,
202- 'naga-staging' : 'nagaStaging' ,
203- } ;
204- const importName = importNameMap [ network ] ;
205- const baseModule : any = ( networks as any ) [ importName ] ;
206-
207- // apply override
208- const mod =
209- typeof baseModule . withOverrides === 'function'
210- ? baseModule . withOverrides ( { rpcUrl : TEST_RPC } )
211- : baseModule ;
212-
213- // log for verification
214- // base vs effective (when override is supported)
215- const baseRpcUrl =
216- typeof baseModule . getRpcUrl === 'function'
217- ? baseModule . getRpcUrl ( )
218- : 'n/a' ;
219- const effRpcUrl =
220- typeof mod . getRpcUrl === 'function' ? mod . getRpcUrl ( ) : 'n/a' ;
221- // eslint-disable-next-line no-console
222- console . log ( '[rpc-override] TEST_RPC:' , TEST_RPC ) ;
223- // eslint-disable-next-line no-console
224- console . log (
225- '[rpc-override] module rpc (base → effective):' ,
226- baseRpcUrl ,
227- '→' ,
228- effRpcUrl
229- ) ;
230- try {
231- const baseChain =
232- typeof baseModule . getChainConfig === 'function'
233- ? baseModule . getChainConfig ( )
234- : null ;
235- const effChain =
236- typeof mod . getChainConfig === 'function' ? mod . getChainConfig ( ) : null ;
237- if ( baseChain && effChain ) {
238- // eslint-disable-next-line no-console
239- console . log (
240- '[rpc-override] module chain id/name (base → effective):' ,
241- `${ baseChain . id } /${ baseChain . name } ` ,
242- '→' ,
243- `${ effChain . id } /${ effChain . name } `
244- ) ;
245- // eslint-disable-next-line no-console
246- console . log (
247- '[rpc-override] module rpcUrls.default.http (base → effective):' ,
248- baseChain . rpcUrls . default . http ,
249- '→' ,
250- effChain . rpcUrls . default . http
251- ) ;
252- // eslint-disable-next-line no-console
253- console . log (
254- '[rpc-override] module rpcUrls.public.http (base → effective):' ,
255- ( baseChain . rpcUrls as any ) [ 'public' ] ?. http ,
256- '→' ,
257- ( effChain . rpcUrls as any ) [ 'public' ] ?. http
258- ) ;
259- }
260- } catch { }
261-
262- // module reflects override
263- expect ( mod . getRpcUrl ( ) ) . toBe ( TEST_RPC ) ;
264- const chain = mod . getChainConfig ( ) ;
265- expect ( chain . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
266- expect ( ( chain . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
267-
268- // client reflects override
269- const { createLitClient } = await import ( '@lit-protocol/lit-client' ) ;
270- const client = await createLitClient ( { network : mod } ) ;
271- const cc = client . getChainConfig ( ) ;
272-
273- // eslint-disable-next-line no-console
274- console . log ( '[rpc-override] client rpcUrl:' , cc . rpcUrl ) ;
275- // eslint-disable-next-line no-console
276- console . log (
277- '[rpc-override] client viem rpcUrls.default:' ,
278- cc . viemConfig . rpcUrls . default . http
279- ) ;
280- // eslint-disable-next-line no-console
281- console . log (
282- '[rpc-override] client viem rpcUrls.public:' ,
283- ( cc . viemConfig . rpcUrls as any ) [ 'public' ] ?. http
284- ) ;
285-
286- expect ( cc . rpcUrl ) . toBe ( TEST_RPC ) ;
287- expect ( cc . viemConfig . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
288- expect ( ( cc . viemConfig . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
289- } ) ;
290- } ) ;
0 commit comments