-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasic.test.ts
More file actions
63 lines (51 loc) · 2.17 KB
/
Copy pathbasic.test.ts
File metadata and controls
63 lines (51 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as fs from "fs";
import * as path from "path";
import { fileURLToPath } from "url";
import { Keypair, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { Program, AnchorProvider, Idl, Wallet } from "@coral-xyz/anchor";
import { LiteSVM } from "litesvm";
import { LiteSVMConnection } from "./utils/litesvm-connection.js";
import { trackInstruction, getCoverageReport } from "./utils/instruction-coverage.js";
import { expect } from "chai";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const omnipairIdlPath = path.join(__dirname, "../target/idl/omnipair.json");
const omnipairIdlData = JSON.parse(fs.readFileSync(omnipairIdlPath, "utf-8")) as any;
// Create a minimal IDL without accounts to avoid parsing issues
const omnipairIdl = {
...omnipairIdlData,
accounts: [] // Remove accounts that cause parsing issues
} as any;
describe("Omnipair Program - Basic Tests", () => {
let svm;
let connection;
let provider;
let program;
let payer;
const OMNIPAIR_PROGRAM_ID = new PublicKey("Bd9Uhf5S8yzfop8cG9oqRs6jVcLtu8B4cb2gvRmtbNzk");
before(async () => {
svm = new LiteSVM();
const programPath = path.join(__dirname, "../target/deploy/omnipair.so");
if (!fs.existsSync(programPath)) {
throw new Error(`Program file not found at ${programPath}`);
}
svm.addProgramFromFile(OMNIPAIR_PROGRAM_ID, programPath);
connection = new LiteSVMConnection(svm);
payer = Keypair.generate();
await connection.requestAirdrop(payer.publicKey, 10 * LAMPORTS_PER_SOL);
const wallet = new Wallet(payer);
provider = new AnchorProvider(connection as any, wallet as any, {});
program = new Program(omnipairIdl as any, OMNIPAIR_PROGRAM_ID as any, provider as any);
});
it("should have initialized the program", async () => {
expect(program).to.not.be.undefined;
expect(program.programId.toString()).to.equal(OMNIPAIR_PROGRAM_ID.toString());
});
it("should have airdropped SOL to payer", async () => {
const balance = await connection.getBalance(payer.publicKey);
expect(balance).to.equal(10 * LAMPORTS_PER_SOL);
});
});
// Display coverage report after basic tests
after(() => {
getCoverageReport();
});