Skip to content

Commit e08a431

Browse files
committed
use import in bankrun tests
1 parent 74259c6 commit e08a431

File tree

25 files changed

+48
-40
lines changed

25 files changed

+48
-40
lines changed

basics/account-data/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BankrunProvider } from 'anchor-bankrun';
55
import { startAnchor } from 'solana-bankrun';
66
import type { AnchorProgramExample } from '../target/types/anchor_program_example';
77

8-
const IDL = require('../target/idl/anchor_program_example.json');
8+
import { IDL } from "../target/idl/anchor_program_example.json";
99
const PROGRAM_ID = new PublicKey(IDL.address);
1010

1111
describe('Account Data!', async () => {

basics/checking-accounts/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BankrunProvider } from 'anchor-bankrun';
55
import { startAnchor } from 'solana-bankrun';
66
import type { AnchorProgramExample } from '../target/types/anchor_program_example';
77

8-
const IDL = require('../target/idl/anchor_program_example.json');
8+
import { IDL } from "../target/idl/anchor_program_example.json";
99
const PROGRAM_ID = new PublicKey(IDL.address);
1010

1111
describe('Bankrun example', async () => {

basics/close-account/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BankrunProvider } from 'anchor-bankrun';
66
import { startAnchor } from 'solana-bankrun';
77
import type { CloseAccountProgram } from '../target/types/close_account_program';
88

9-
const IDL = require('../target/idl/close_account_program.json');
9+
import { IDL } from "../target/idl/close_account_program.json";
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

1212
describe('close-an-account', async () => {

basics/counter/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { assert } from 'chai';
66
import { startAnchor } from 'solana-bankrun';
77
import type { CounterAnchor } from '../target/types/counter_anchor';
88

9-
const IDL = require('../target/idl/counter_anchor.json');
9+
import { IDL } from "../target/idl/counter_anchor.json";
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

1212
describe('counter_anchor', async () => {

basics/create-account/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { assert } from 'chai';
66
import { startAnchor } from 'solana-bankrun';
77
import type { CreateSystemAccount } from '../target/types/create_system_account';
88

9-
const IDL = require('../target/idl/create_system_account.json');
9+
import { IDL } from "../target/idl/create_system_account.json";
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

1212
describe('Create a system account', async () => {

basics/cross-program-invocation/anchor/tests/bankrun.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { startAnchor } from 'solana-bankrun';
66
import type { Hand } from '../target/types/hand';
77
import type { Lever } from '../target/types/lever';
88

9-
const HAND_IDL = require('../target/idl/hand.json');
10-
const LEVER_IDL = require('../target/idl/lever.json');
9+
import { IDL as HAND_IDL } from "../target/idl/hand.json";
10+
import { IDL as LEVER_IDL } from "../target/idl/lever.json";
1111
const HAND_PROGRAM_ID = new PublicKey(HAND_IDL.address);
1212
const LEVER_PROGRAM_ID = new PublicKey(LEVER_IDL.address);
1313

basics/favorites/anchor/tests/favorites-bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Favorites } from '../target/types/favorites';
99
import { systemProgramErrors } from './system-errors';
1010

1111
const web3 = anchor.web3;
12-
const IDL = require('../target/idl/favorites.json');
12+
import { IDL } from "../target/idl/favorites.json";
1313
const PROGRAM_ID = new PublicKey(IDL.address);
1414

1515
describe('Favorites Bankrun', async () => {

basics/hello-solana/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BankrunProvider } from 'anchor-bankrun';
55
import { startAnchor } from 'solana-bankrun';
66
import { HelloSolana } from '../target/types/hello_solana';
77

8-
const IDL = require('../target/idl/hello_solana.json');
8+
import { IDL } from "../target/idl/hello_solana.json";
99
const PROGRAM_ID = new PublicKey(IDL.address);
1010

1111
describe('hello-solana', async () => {

basics/pda-rent-payer/anchor/tests/bankrun.test.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
import { describe, it } from 'node:test';
2-
import * as anchor from '@coral-xyz/anchor';
3-
import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';
4-
import { BankrunProvider } from 'anchor-bankrun';
5-
import { assert } from 'chai';
6-
import { startAnchor } from 'solana-bankrun';
7-
import type { PdaRentPayer } from '../target/types/pda_rent_payer';
8-
9-
const IDL = require('../target/idl/pda_rent_payer.json');
1+
import { describe, it } from "node:test";
2+
import * as anchor from "@coral-xyz/anchor";
3+
import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
4+
import { BankrunProvider } from "anchor-bankrun";
5+
import { assert } from "chai";
6+
import { startAnchor } from "solana-bankrun";
7+
import type { PdaRentPayer } from "../target/types/pda_rent_payer";
8+
9+
import { IDL } from "../target/idl/pda_rent_payer.json";
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

12-
describe('PDA Rent-Payer', async () => {
13-
const context = await startAnchor('', [{ name: 'pda_rent_payer', programId: PROGRAM_ID }], []);
12+
describe("PDA Rent-Payer", async () => {
13+
const context = await startAnchor(
14+
"",
15+
[{ name: "pda_rent_payer", programId: PROGRAM_ID }],
16+
[],
17+
);
1418
const provider = new BankrunProvider(context);
1519
const program = new anchor.Program<PdaRentPayer>(IDL, provider);
1620

1721
const wallet = provider.wallet as anchor.Wallet;
1822
const connection = provider.connection;
1923

2024
// PDA for the Rent Vault
21-
const [rentVaultPDA] = PublicKey.findProgramAddressSync([Buffer.from('rent_vault')], program.programId);
25+
const [rentVaultPDA] = PublicKey.findProgramAddressSync(
26+
[Buffer.from("rent_vault")],
27+
program.programId,
28+
);
2229

23-
it('Initialize the Rent Vault', async () => {
30+
it("Initialize the Rent Vault", async () => {
2431
// 1 SOL
2532
const fundAmount = new anchor.BN(LAMPORTS_PER_SOL);
2633

@@ -32,11 +39,12 @@ describe('PDA Rent-Payer', async () => {
3239
.rpc();
3340

3441
// Check rent vault balance
35-
const accountInfo = await program.provider.connection.getAccountInfo(rentVaultPDA);
42+
const accountInfo =
43+
await program.provider.connection.getAccountInfo(rentVaultPDA);
3644
assert(accountInfo.lamports === fundAmount.toNumber());
3745
});
3846

39-
it('Create a new account using the Rent Vault', async () => {
47+
it("Create a new account using the Rent Vault", async () => {
4048
// Generate a new keypair for the new account
4149
const newAccount = new Keypair();
4250

basics/processing-instructions/anchor/tests/bankrun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BankrunProvider } from 'anchor-bankrun';
55
import { startAnchor } from 'solana-bankrun';
66
import type { ProcessingInstructions } from '../target/types/processing_instructions';
77

8-
const IDL = require('../target/idl/processing_instructions.json');
8+
import { IDL } from "../target/idl/processing_instructions.json";
99
const PROGRAM_ID = new PublicKey(IDL.address);
1010

1111
describe('custom-instruction-data', async () => {

0 commit comments

Comments
 (0)