@@ -19,21 +19,29 @@ import {
1919} from './helper/tests' ;
2020import { init } from './init' ;
2121
22+ const RPC_OVERRIDE = process . env [ 'LIT_YELLOWSTONE_PRIVATE_RPC_URL' ] ;
23+ if ( RPC_OVERRIDE ) {
24+ console . log (
25+ '🧪 E2E: Using RPC override (LIT_YELLOWSTONE_PRIVATE_RPC_URL):' ,
26+ RPC_OVERRIDE
27+ ) ;
28+ }
29+
2230describe ( 'all' , ( ) => {
2331 // Singleton baby
2432 let ctx : Awaited < ReturnType < typeof init > > ;
2533
2634 // Auth contexts for testing
2735 let alicePkpAuthContext : any ;
28- let aliceCustomAuthContext : any ;
36+ let eveCustomAuthContext : any ;
2937
3038 beforeAll ( async ( ) => {
3139 try {
3240 ctx = await init ( ) ;
3341
3442 // Create PKP and custom auth contexts using helper functions
3543 // alicePkpAuthContext = await createPkpAuthContext(ctx);
36- aliceCustomAuthContext = await createCustomAuthContext ( ctx ) ;
44+ eveCustomAuthContext = await createCustomAuthContext ( ctx ) ;
3745 } catch ( e ) {
3846 console . error ( e ) ;
3947 process . exit ( 1 ) ;
@@ -48,10 +56,12 @@ describe('all', () => {
4856 createPkpSignTest ( ctx , ( ) => ctx . aliceEoaAuthContext ) ( ) ) ;
4957 it ( 'executeJs' , ( ) =>
5058 createExecuteJsTest ( ctx , ( ) => ctx . aliceEoaAuthContext ) ( ) ) ;
51- it ( 'viewPKPsByAddress' , ( ) =>
52- createViewPKPsByAddressTest ( ctx , ( ) => ctx . aliceEoaAuthContext ) ( ) ) ;
59+ it ( 'viewPKPsByAddress' , ( ) => createViewPKPsByAddressTest ( ctx ) ( ) ) ;
5360 it ( 'viewPKPsByAuthData' , ( ) =>
54- createViewPKPsByAuthDataTest ( ctx , ( ) => ctx . aliceEoaAuthContext ) ( ) ) ;
61+ createViewPKPsByAuthDataTest (
62+ ctx ,
63+ ctx . aliceViemAccountAuthData
64+ ) ( ) ) ;
5565 it ( 'pkpEncryptDecrypt' , ( ) =>
5666 createPkpEncryptDecryptTest ( ctx , ( ) => ctx . aliceEoaAuthContext ) ( ) ) ;
5767 it ( 'encryptDecryptFlow' , ( ) =>
@@ -90,9 +100,12 @@ describe('all', () => {
90100 it ( 'executeJs' , ( ) =>
91101 createExecuteJsTest ( ctx , ( ) => ctx . alicePkpAuthContext ) ( ) ) ;
92102 it ( 'viewPKPsByAddress' , ( ) =>
93- createViewPKPsByAddressTest ( ctx , ( ) => ctx . alicePkpAuthContext ) ( ) ) ;
103+ createViewPKPsByAddressTest ( ctx ) ( ) ) ;
94104 it ( 'viewPKPsByAuthData' , ( ) =>
95- createViewPKPsByAuthDataTest ( ctx , ( ) => ctx . alicePkpAuthContext ) ( ) ) ;
105+ createViewPKPsByAuthDataTest (
106+ ctx ,
107+ ctx . aliceViemAccountAuthData
108+ ) ( ) ) ;
96109 it ( 'pkpEncryptDecrypt' , ( ) =>
97110 createPkpEncryptDecryptTest ( ctx , ( ) => ctx . alicePkpAuthContext ) ( ) ) ;
98111 it ( 'encryptDecryptFlow' , ( ) =>
@@ -124,34 +137,51 @@ describe('all', () => {
124137
125138 describe ( 'endpoints' , ( ) => {
126139 it ( 'pkpSign' , ( ) =>
127- createPkpSignTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
140+ createPkpSignTest (
141+ ctx ,
142+ ( ) => eveCustomAuthContext ,
143+ ctx . eveViemAccountPkp . pubkey
144+ ) ( ) ) ;
128145 it ( 'executeJs' , ( ) =>
129- createExecuteJsTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
130- it ( 'viewPKPsByAddress' , ( ) =>
131- createViewPKPsByAddressTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
146+ createExecuteJsTest (
147+ ctx ,
148+ ( ) => eveCustomAuthContext ,
149+ ctx . eveViemAccountPkp . pubkey
150+ ) ( ) ) ;
151+ it ( 'viewPKPsByAddress' , ( ) => createViewPKPsByAddressTest ( ctx ) ( ) ) ;
132152 it ( 'viewPKPsByAuthData' , ( ) =>
133- createViewPKPsByAuthDataTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
153+ createViewPKPsByAuthDataTest ( ctx , ctx . eveCustomAuthData ) ( ) ) ;
134154 it ( 'pkpEncryptDecrypt' , ( ) =>
135- createPkpEncryptDecryptTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
155+ createPkpEncryptDecryptTest (
156+ ctx ,
157+ ( ) => eveCustomAuthContext ,
158+ ctx . eveViemAccountPkp . ethAddress
159+ ) ( ) ) ;
136160 it ( 'encryptDecryptFlow' , ( ) =>
137- createEncryptDecryptFlowTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
138- it ( 'pkpPermissionsManagerFlow' , ( ) =>
139- createPkpPermissionsManagerFlowTest (
161+ createEncryptDecryptFlowTest (
140162 ctx ,
141- ( ) => aliceCustomAuthContext
163+ ( ) => eveCustomAuthContext ,
164+ ctx . eveViemAccountPkp . pubkey
142165 ) ( ) ) ;
143- } ) ;
144166
145- describe ( 'integrations' , ( ) => {
146- describe ( 'pkp viem account' , ( ) => {
147- it ( 'sign message' , ( ) =>
148- createViemSignMessageTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
149- it ( 'sign transaction' , ( ) =>
150- createViemSignTransactionTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
151- it ( 'sign typed data' , ( ) =>
152- createViemSignTypedDataTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
153- } ) ;
167+ // Disable for now because it requires a different flow
168+ // it('pkpPermissionsManagerFlow', () =>
169+ // createPkpPermissionsManagerFlowTest(
170+ // ctx,
171+ // () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey
172+ // )());
154173 } ) ;
174+
175+ // describe('integrations', () => {
176+ // describe('pkp viem account', () => {
177+ // it('sign message', () =>
178+ // createViemSignMessageTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
179+ // it('sign transaction', () =>
180+ // createViemSignTransactionTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
181+ // it('sign typed data', () =>
182+ // createViemSignTypedDataTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
183+ // });
184+ // });
155185 } ) ;
156186
157187 describe ( 'EOA Native' , ( ) => {
@@ -161,3 +191,114 @@ describe('all', () => {
161191 } ) ;
162192 } ) ;
163193} ) ;
194+
195+ describe ( 'rpc override' , ( ) => {
196+ const TEST_RPC = process . env . LIT_YELLOWSTONE_PRIVATE_RPC_URL ;
197+ // const TEST_RPC = 'https://yellowstone-override.example';
198+
199+ // beforeAll(() => {
200+ // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = TEST_RPC;
201+ // });
202+
203+ // afterAll(() => {
204+ // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = ORIGINAL_RPC;
205+ // });
206+
207+ it ( 'applies env rpc override to module and client' , async ( ) => {
208+ const networks = await import ( '@lit-protocol/networks' ) ;
209+
210+ // choose module by NETWORK env (same way init.ts does)
211+ const network = process . env . NETWORK || 'naga-dev' ;
212+ const importNameMap : Record < string , string > = {
213+ 'naga-dev' : 'nagaDev' ,
214+ 'naga-test' : 'nagaTest' ,
215+ 'naga-local' : 'nagaLocal' ,
216+ 'naga-staging' : 'nagaStaging' ,
217+ } ;
218+ const importName = importNameMap [ network ] ;
219+ const baseModule : any = ( networks as any ) [ importName ] ;
220+
221+ // apply override
222+ const mod =
223+ typeof baseModule . withOverrides === 'function'
224+ ? baseModule . withOverrides ( { rpcUrl : TEST_RPC } )
225+ : baseModule ;
226+
227+ // log for verification
228+ // base vs effective (when override is supported)
229+ const baseRpcUrl =
230+ typeof baseModule . getRpcUrl === 'function'
231+ ? baseModule . getRpcUrl ( )
232+ : 'n/a' ;
233+ const effRpcUrl =
234+ typeof mod . getRpcUrl === 'function' ? mod . getRpcUrl ( ) : 'n/a' ;
235+ // eslint-disable-next-line no-console
236+ console . log ( '[rpc-override] TEST_RPC:' , TEST_RPC ) ;
237+ // eslint-disable-next-line no-console
238+ console . log (
239+ '[rpc-override] module rpc (base → effective):' ,
240+ baseRpcUrl ,
241+ '→' ,
242+ effRpcUrl
243+ ) ;
244+ try {
245+ const baseChain =
246+ typeof baseModule . getChainConfig === 'function'
247+ ? baseModule . getChainConfig ( )
248+ : null ;
249+ const effChain =
250+ typeof mod . getChainConfig === 'function' ? mod . getChainConfig ( ) : null ;
251+ if ( baseChain && effChain ) {
252+ // eslint-disable-next-line no-console
253+ console . log (
254+ '[rpc-override] module chain id/name (base → effective):' ,
255+ `${ baseChain . id } /${ baseChain . name } ` ,
256+ '→' ,
257+ `${ effChain . id } /${ effChain . name } `
258+ ) ;
259+ // eslint-disable-next-line no-console
260+ console . log (
261+ '[rpc-override] module rpcUrls.default.http (base → effective):' ,
262+ baseChain . rpcUrls . default . http ,
263+ '→' ,
264+ effChain . rpcUrls . default . http
265+ ) ;
266+ // eslint-disable-next-line no-console
267+ console . log (
268+ '[rpc-override] module rpcUrls.public.http (base → effective):' ,
269+ ( baseChain . rpcUrls as any ) [ 'public' ] ?. http ,
270+ '→' ,
271+ ( effChain . rpcUrls as any ) [ 'public' ] ?. http
272+ ) ;
273+ }
274+ } catch { }
275+
276+ // module reflects override
277+ expect ( mod . getRpcUrl ( ) ) . toBe ( TEST_RPC ) ;
278+ const chain = mod . getChainConfig ( ) ;
279+ expect ( chain . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
280+ expect ( ( chain . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
281+
282+ // client reflects override
283+ const { createLitClient } = await import ( '@lit-protocol/lit-client' ) ;
284+ const client = await createLitClient ( { network : mod } ) ;
285+ const cc = client . getChainConfig ( ) ;
286+
287+ // eslint-disable-next-line no-console
288+ console . log ( '[rpc-override] client rpcUrl:' , cc . rpcUrl ) ;
289+ // eslint-disable-next-line no-console
290+ console . log (
291+ '[rpc-override] client viem rpcUrls.default:' ,
292+ cc . viemConfig . rpcUrls . default . http
293+ ) ;
294+ // eslint-disable-next-line no-console
295+ console . log (
296+ '[rpc-override] client viem rpcUrls.public:' ,
297+ ( cc . viemConfig . rpcUrls as any ) [ 'public' ] ?. http
298+ ) ;
299+
300+ expect ( cc . rpcUrl ) . toBe ( TEST_RPC ) ;
301+ expect ( cc . viemConfig . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
302+ expect ( ( cc . viemConfig . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
303+ } ) ;
304+ } ) ;
0 commit comments