Skip to content

Commit 9a1cd07

Browse files
committed
fix(e2e): ensure all tests pass
1 parent 83bd3ba commit 9a1cd07

File tree

5 files changed

+244
-251
lines changed

5 files changed

+244
-251
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// WIP! Use e2e.spec.ts instead
2+
import { createEnvVars } from './helper/createEnvVars';
3+
import { createTestEnv } from './helper/createTestEnv';
4+
import {
5+
createTestAccount,
6+
CreateTestAccountResult,
7+
} from './helper/createTestAccount';
8+
9+
const registerEoaExecuteJsSuite = () => {
10+
describe('EOA auth (revamp)', () => {
11+
let testEnv: Awaited<ReturnType<typeof createTestEnv>>;
12+
let alice: CreateTestAccountResult;
13+
14+
beforeAll(async () => {
15+
const envVars = createEnvVars();
16+
testEnv = await createTestEnv(envVars);
17+
18+
alice = await createTestAccount(testEnv, {
19+
label: 'Alice',
20+
fundAccount: true,
21+
hasEoaAuthContext: true,
22+
fundLedger: true,
23+
hasPKP: true,
24+
fundPKP: true,
25+
hasPKPAuthContext: true,
26+
fundPKPLedger: true,
27+
});
28+
});
29+
30+
test('executeJs signs with Alice PKP', async () => {
31+
if (!alice.eoaAuthContext) {
32+
throw new Error('Alice is missing an EOA auth context');
33+
}
34+
if (!alice.pkp) {
35+
throw new Error('Alice is missing a PKP');
36+
}
37+
38+
const litActionCode = `
39+
(async () => {
40+
const { sigName, toSign, publicKey } = jsParams;
41+
const { keccak256, arrayify } = ethers.utils;
42+
43+
const toSignBytes = new TextEncoder().encode(toSign);
44+
const toSignBytes32 = keccak256(toSignBytes);
45+
const toSignBytes32Array = arrayify(toSignBytes32);
46+
47+
const sigShare = await Lit.Actions.signEcdsa({
48+
toSign: toSignBytes32Array,
49+
publicKey,
50+
sigName,
51+
});
52+
})();`;
53+
54+
const toSign = 'Revamp executeJs test';
55+
const result = await testEnv.litClient.executeJs({
56+
code: litActionCode,
57+
authContext: alice.eoaAuthContext,
58+
jsParams: {
59+
message: toSign,
60+
sigName: 'revamp-e2e-sig',
61+
toSign,
62+
publicKey: alice.pkp.pubkey,
63+
},
64+
});
65+
66+
expect(result).toBeDefined();
67+
expect(result.signatures).toBeDefined();
68+
});
69+
});
70+
};
71+
72+
describe('revamped e2e suite', () => {
73+
registerEoaExecuteJsSuite();
74+
});

0 commit comments

Comments
 (0)