Skip to content

Commit 5d808b3

Browse files
onspeedhpclaude
andcommitted
fix(tests-sdk): pass PROGRAM_ID explicitly to LazorKitClient constructor
sdk-legacy's LazorKitClient infers programId from the RPC URL when the second arg is omitted, defaulting localhost to the commercial devnet ID (4h3X…). Tests target the program-v2 binary loaded at the keypair pubkey, so the inference returns the wrong ID and all txs fail with "Attempt to load a program that does not exist". Pass PROGRAM_ID explicitly across all 9 test files. Also added the PROGRAM_ID import to 02-authority, 03-execute, 04-session, 07-e2e, 09-permissions, 10-session-execute (the others already had it). After this fix, vitest results against a live local validator: 35 passed | 28 failed | 2 skipped (65 total) The 28 remaining failures are ALL Secp256r1 paths. Root cause: program-v2's on-chain auth code still uses the OLD typeAndFlags format (extracts a single byte from auth_payload[13] and reconstructs clientDataJson on-chain), while sdk-legacy's mock signer uses the NEW format (embeds full clientDataJson directly in the payload). lazorkit-protocol's auth was upgraded to the new format; program-v2's wasn't ported. Fixing this requires porting lazorkit-protocol/program/src/auth/secp256r1/ to program-v2 — substantial change with audit attention. Tracked as follow-up. Ed25519 paths all pass. The 9 new E2E action tests (12-actions.test.ts) all pass since they use Ed25519 admin signers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0c5b5a6 commit 5d808b3

8 files changed

Lines changed: 14 additions & 10 deletions

tests-sdk/tests/01-wallet.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('CreateWallet', () => {
1616

1717
beforeAll(async () => {
1818
ctx = await setupTest();
19-
client = new LazorKitClient(ctx.connection);
19+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
2020
});
2121

2222
it('creates a wallet with Ed25519 owner', async () => {

tests-sdk/tests/02-authority.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
setupTest,
66
sendTx,
77
sendTxExpectError,
8+
PROGRAM_ID,
89
type TestContext,
910
} from './common';
1011
import { generateMockSecp256r1Key, createMockSigner } from './secp256r1Utils';
@@ -25,7 +26,7 @@ describe('Authority Management', () => {
2526

2627
beforeAll(async () => {
2728
ctx = await setupTest();
28-
client = new LazorKitClient(ctx.connection);
29+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
2930
});
3031

3132
describe('Ed25519 admin flow', () => {

tests-sdk/tests/03-execute.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
LAMPORTS_PER_SOL,
77
} from '@solana/web3.js';
88
import * as crypto from 'crypto';
9-
import { setupTest, sendTx, type TestContext } from './common';
9+
import { setupTest, sendTx, PROGRAM_ID, type TestContext } from './common';
1010
import { generateMockSecp256r1Key, createMockSigner } from './secp256r1Utils';
1111
import {
1212
LazorKitClient,
@@ -20,7 +20,7 @@ describe('Execute', () => {
2020

2121
beforeAll(async () => {
2222
ctx = await setupTest();
23-
client = new LazorKitClient(ctx.connection);
23+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
2424
});
2525

2626
describe('Ed25519 Execute', () => {

tests-sdk/tests/04-session.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Keypair } from '@solana/web3.js';
33
import * as crypto from 'crypto';
44
import {
55
setupTest,
6+
PROGRAM_ID,
67
sendTx,
78
sendTxExpectError,
89
getSlot,
@@ -20,7 +21,7 @@ describe('CreateSession', () => {
2021

2122
beforeAll(async () => {
2223
ctx = await setupTest();
23-
client = new LazorKitClient(ctx.connection);
24+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
2425

2526
ownerKp = Keypair.generate();
2627
const userSeed = crypto.randomBytes(32);

tests-sdk/tests/07-e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
LAMPORTS_PER_SOL,
66
} from '@solana/web3.js';
77
import * as crypto from 'crypto';
8-
import { setupTest, sendTx, getSlot, type TestContext } from './common';
8+
import { setupTest, sendTx, PROGRAM_ID, getSlot, type TestContext } from './common';
99
import { generateMockSecp256r1Key, createMockSigner } from './secp256r1Utils';
1010
import {
1111
LazorKitClient,
@@ -44,7 +44,7 @@ describe('E2E Company Workflow', () => {
4444

4545
beforeAll(async () => {
4646
ctx = await setupTest();
47-
client = new LazorKitClient(ctx.connection);
47+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
4848
ceoKey = await generateMockSecp256r1Key('company.com');
4949
adminKp = Keypair.generate();
5050
spenderKey = await generateMockSecp256r1Key('company.com');

tests-sdk/tests/09-permissions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';
1313
import * as crypto from 'crypto';
1414
import {
1515
setupTest,
16+
PROGRAM_ID,
1617
sendTx,
1718
sendTxExpectError,
1819
getSlot,
@@ -44,7 +45,7 @@ describe('Permission Boundaries', () => {
4445

4546
beforeAll(async () => {
4647
ctx = await setupTest();
47-
client = new LazorKitClient(ctx.connection);
48+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
4849

4950
// Create wallet with Ed25519 owner
5051
ownerKp = Keypair.generate();

tests-sdk/tests/10-session-execute.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import * as crypto from 'crypto';
1717
import {
1818
setupTest,
19+
PROGRAM_ID,
1920
sendTx,
2021
sendTxExpectError,
2122
getSlot,
@@ -38,7 +39,7 @@ describe('Session Execute', () => {
3839

3940
beforeAll(async () => {
4041
ctx = await setupTest();
41-
client = new LazorKitClient(ctx.connection);
42+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
4243

4344
ownerKp = Keypair.generate();
4445
const userSeed = crypto.randomBytes(32);

tests-sdk/tests/11-security.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Security', () => {
4949

5050
beforeAll(async () => {
5151
ctx = await setupTest();
52-
client = new LazorKitClient(ctx.connection);
52+
client = new LazorKitClient(ctx.connection, PROGRAM_ID);
5353
});
5454

5555
// ─── Counter increment verification ─────────────────────────────

0 commit comments

Comments
 (0)