@@ -19,21 +19,29 @@ import {
19
19
} from './helper/tests' ;
20
20
import { init } from './init' ;
21
21
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
+
22
30
describe ( 'all' , ( ) => {
23
31
// Singleton baby
24
32
let ctx : Awaited < ReturnType < typeof init > > ;
25
33
26
34
// Auth contexts for testing
27
35
let alicePkpAuthContext : any ;
28
- let aliceCustomAuthContext : any ;
36
+ let eveCustomAuthContext : any ;
29
37
30
38
beforeAll ( async ( ) => {
31
39
try {
32
40
ctx = await init ( ) ;
33
41
34
42
// Create PKP and custom auth contexts using helper functions
35
43
// alicePkpAuthContext = await createPkpAuthContext(ctx);
36
- aliceCustomAuthContext = await createCustomAuthContext ( ctx ) ;
44
+ eveCustomAuthContext = await createCustomAuthContext ( ctx ) ;
37
45
} catch ( e ) {
38
46
console . error ( e ) ;
39
47
process . exit ( 1 ) ;
@@ -124,34 +132,51 @@ describe('all', () => {
124
132
125
133
describe ( 'endpoints' , ( ) => {
126
134
it ( 'pkpSign' , ( ) =>
127
- createPkpSignTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
135
+ createPkpSignTest (
136
+ ctx ,
137
+ ( ) => eveCustomAuthContext ,
138
+ ctx . eveViemAccountPkp . pubkey
139
+ ) ( ) ) ;
128
140
it ( 'executeJs' , ( ) =>
129
- createExecuteJsTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
130
- it ( 'viewPKPsByAddress' , ( ) =>
131
- createViewPKPsByAddressTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
141
+ createExecuteJsTest (
142
+ ctx ,
143
+ ( ) => eveCustomAuthContext ,
144
+ ctx . eveViemAccountPkp . pubkey
145
+ ) ( ) ) ;
146
+ it ( 'viewPKPsByAddress' , ( ) => createViewPKPsByAddressTest ( ctx ) ( ) ) ;
132
147
it ( 'viewPKPsByAuthData' , ( ) =>
133
- createViewPKPsByAuthDataTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
148
+ createViewPKPsByAuthDataTest ( ctx , ctx . eveCustomAuthData ) ( ) ) ;
134
149
it ( 'pkpEncryptDecrypt' , ( ) =>
135
- createPkpEncryptDecryptTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
150
+ createPkpEncryptDecryptTest (
151
+ ctx ,
152
+ ( ) => eveCustomAuthContext ,
153
+ ctx . eveViemAccountPkp . ethAddress
154
+ ) ( ) ) ;
136
155
it ( 'encryptDecryptFlow' , ( ) =>
137
- createEncryptDecryptFlowTest ( ctx , ( ) => aliceCustomAuthContext ) ( ) ) ;
138
- it ( 'pkpPermissionsManagerFlow' , ( ) =>
139
- createPkpPermissionsManagerFlowTest (
156
+ createEncryptDecryptFlowTest (
140
157
ctx ,
141
- ( ) => aliceCustomAuthContext
158
+ ( ) => eveCustomAuthContext ,
159
+ ctx . eveViemAccountPkp . pubkey
142
160
) ( ) ) ;
143
- } ) ;
144
161
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
- } ) ;
162
+ // Disable for now because it requires a different flow
163
+ // it('pkpPermissionsManagerFlow', () =>
164
+ // createPkpPermissionsManagerFlowTest(
165
+ // ctx,
166
+ // () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey
167
+ // )());
154
168
} ) ;
169
+
170
+ // describe('integrations', () => {
171
+ // describe('pkp viem account', () => {
172
+ // it('sign message', () =>
173
+ // createViemSignMessageTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
174
+ // it('sign transaction', () =>
175
+ // createViemSignTransactionTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
176
+ // it('sign typed data', () =>
177
+ // createViemSignTypedDataTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
178
+ // });
179
+ // });
155
180
} ) ;
156
181
157
182
describe ( 'EOA Native' , ( ) => {
@@ -161,3 +186,114 @@ describe('all', () => {
161
186
} ) ;
162
187
} ) ;
163
188
} ) ;
189
+
190
+ describe ( 'rpc override' , ( ) => {
191
+ const TEST_RPC = process . env . LIT_YELLOWSTONE_PRIVATE_RPC_URL ;
192
+ // const TEST_RPC = 'https://yellowstone-override.example';
193
+
194
+ // beforeAll(() => {
195
+ // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = TEST_RPC;
196
+ // });
197
+
198
+ // afterAll(() => {
199
+ // process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = ORIGINAL_RPC;
200
+ // });
201
+
202
+ it ( 'applies env rpc override to module and client' , async ( ) => {
203
+ const networks = await import ( '@lit-protocol/networks' ) ;
204
+
205
+ // choose module by NETWORK env (same way init.ts does)
206
+ const network = process . env . NETWORK || 'naga-dev' ;
207
+ const importNameMap : Record < string , string > = {
208
+ 'naga-dev' : 'nagaDev' ,
209
+ 'naga-test' : 'nagaTest' ,
210
+ 'naga-local' : 'nagaLocal' ,
211
+ 'naga-staging' : 'nagaStaging' ,
212
+ } ;
213
+ const importName = importNameMap [ network ] ;
214
+ const baseModule : any = ( networks as any ) [ importName ] ;
215
+
216
+ // apply override
217
+ const mod =
218
+ typeof baseModule . withOverrides === 'function'
219
+ ? baseModule . withOverrides ( { rpcUrl : TEST_RPC } )
220
+ : baseModule ;
221
+
222
+ // log for verification
223
+ // base vs effective (when override is supported)
224
+ const baseRpcUrl =
225
+ typeof baseModule . getRpcUrl === 'function'
226
+ ? baseModule . getRpcUrl ( )
227
+ : 'n/a' ;
228
+ const effRpcUrl =
229
+ typeof mod . getRpcUrl === 'function' ? mod . getRpcUrl ( ) : 'n/a' ;
230
+ // eslint-disable-next-line no-console
231
+ console . log ( '[rpc-override] TEST_RPC:' , TEST_RPC ) ;
232
+ // eslint-disable-next-line no-console
233
+ console . log (
234
+ '[rpc-override] module rpc (base → effective):' ,
235
+ baseRpcUrl ,
236
+ '→' ,
237
+ effRpcUrl
238
+ ) ;
239
+ try {
240
+ const baseChain =
241
+ typeof baseModule . getChainConfig === 'function'
242
+ ? baseModule . getChainConfig ( )
243
+ : null ;
244
+ const effChain =
245
+ typeof mod . getChainConfig === 'function' ? mod . getChainConfig ( ) : null ;
246
+ if ( baseChain && effChain ) {
247
+ // eslint-disable-next-line no-console
248
+ console . log (
249
+ '[rpc-override] module chain id/name (base → effective):' ,
250
+ `${ baseChain . id } /${ baseChain . name } ` ,
251
+ '→' ,
252
+ `${ effChain . id } /${ effChain . name } `
253
+ ) ;
254
+ // eslint-disable-next-line no-console
255
+ console . log (
256
+ '[rpc-override] module rpcUrls.default.http (base → effective):' ,
257
+ baseChain . rpcUrls . default . http ,
258
+ '→' ,
259
+ effChain . rpcUrls . default . http
260
+ ) ;
261
+ // eslint-disable-next-line no-console
262
+ console . log (
263
+ '[rpc-override] module rpcUrls.public.http (base → effective):' ,
264
+ ( baseChain . rpcUrls as any ) [ 'public' ] ?. http ,
265
+ '→' ,
266
+ ( effChain . rpcUrls as any ) [ 'public' ] ?. http
267
+ ) ;
268
+ }
269
+ } catch { }
270
+
271
+ // module reflects override
272
+ expect ( mod . getRpcUrl ( ) ) . toBe ( TEST_RPC ) ;
273
+ const chain = mod . getChainConfig ( ) ;
274
+ expect ( chain . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
275
+ expect ( ( chain . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
276
+
277
+ // client reflects override
278
+ const { createLitClient } = await import ( '@lit-protocol/lit-client' ) ;
279
+ const client = await createLitClient ( { network : mod } ) ;
280
+ const cc = client . getChainConfig ( ) ;
281
+
282
+ // eslint-disable-next-line no-console
283
+ console . log ( '[rpc-override] client rpcUrl:' , cc . rpcUrl ) ;
284
+ // eslint-disable-next-line no-console
285
+ console . log (
286
+ '[rpc-override] client viem rpcUrls.default:' ,
287
+ cc . viemConfig . rpcUrls . default . http
288
+ ) ;
289
+ // eslint-disable-next-line no-console
290
+ console . log (
291
+ '[rpc-override] client viem rpcUrls.public:' ,
292
+ ( cc . viemConfig . rpcUrls as any ) [ 'public' ] ?. http
293
+ ) ;
294
+
295
+ expect ( cc . rpcUrl ) . toBe ( TEST_RPC ) ;
296
+ expect ( cc . viemConfig . rpcUrls . default . http [ 0 ] ) . toBe ( TEST_RPC ) ;
297
+ expect ( ( cc . viemConfig . rpcUrls as any ) [ 'public' ] . http [ 0 ] ) . toBe ( TEST_RPC ) ;
298
+ } ) ;
299
+ } ) ;
0 commit comments