Skip to content

Commit 8a8163f

Browse files
committed
refactor(e2e): moved ./e2e inside ./packages/e2e
1 parent 0edeb1f commit 8a8163f

File tree

1 file changed

+166
-21
lines changed

1 file changed

+166
-21
lines changed

packages/e2e/src/e2e.spec.ts

Lines changed: 166 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,29 @@ import {
1919
} from './helper/tests';
2020
import { 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+
2230
describe('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);
@@ -124,34 +132,60 @@ describe('all', () => {
124132

125133
describe('endpoints', () => {
126134
it('pkpSign', () =>
127-
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
135+
createPkpSignTest(
136+
ctx,
137+
() => eveCustomAuthContext,
138+
ctx.eveViemAccountPkp.pubkey
139+
)());
128140
it('executeJs', () =>
129-
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
141+
createExecuteJsTest(
142+
ctx,
143+
() => eveCustomAuthContext,
144+
ctx.eveViemAccountPkp.pubkey
145+
)());
130146
it('viewPKPsByAddress', () =>
131-
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
147+
createViewPKPsByAddressTest(
148+
ctx,
149+
() => eveCustomAuthContext,
150+
ctx.eveViemAccountPkp.pubkey
151+
)());
132152
it('viewPKPsByAuthData', () =>
133-
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
153+
createViewPKPsByAuthDataTest(
154+
ctx,
155+
() => eveCustomAuthContext,
156+
ctx.eveCustomAuthData
157+
)());
134158
it('pkpEncryptDecrypt', () =>
135-
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
159+
createPkpEncryptDecryptTest(
160+
ctx,
161+
() => eveCustomAuthContext,
162+
ctx.eveViemAccountPkp.ethAddress
163+
)());
136164
it('encryptDecryptFlow', () =>
137-
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
138-
it('pkpPermissionsManagerFlow', () =>
139-
createPkpPermissionsManagerFlowTest(
165+
createEncryptDecryptFlowTest(
140166
ctx,
141-
() => aliceCustomAuthContext
167+
() => eveCustomAuthContext,
168+
ctx.eveViemAccountPkp.pubkey
142169
)());
143-
});
144170

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-
});
171+
// Disable for now because it requires a different flow
172+
// it('pkpPermissionsManagerFlow', () =>
173+
// createPkpPermissionsManagerFlowTest(
174+
// ctx,
175+
// () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey
176+
// )());
154177
});
178+
179+
// describe('integrations', () => {
180+
// describe('pkp viem account', () => {
181+
// it('sign message', () =>
182+
// createViemSignMessageTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
183+
// it('sign transaction', () =>
184+
// createViemSignTransactionTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
185+
// it('sign typed data', () =>
186+
// createViemSignTypedDataTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
187+
// });
188+
// });
155189
});
156190

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

0 commit comments

Comments
 (0)