Skip to content

Commit 3c8490b

Browse files
committed
remove curly braces from bankrun tests
1 parent e08a431 commit 3c8490b

File tree

25 files changed

+997
-594
lines changed

25 files changed

+997
-594
lines changed

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import { describe, it } from 'node:test';
2-
import * as anchor from '@coral-xyz/anchor';
3-
import { Keypair, PublicKey } from '@solana/web3.js';
4-
import { BankrunProvider } from 'anchor-bankrun';
5-
import { startAnchor } from 'solana-bankrun';
6-
import type { AnchorProgramExample } from '../target/types/anchor_program_example';
7-
8-
import { IDL } from "../target/idl/anchor_program_example.json";
1+
import { describe, it } from "node:test";
2+
import * as anchor from "@coral-xyz/anchor";
3+
import { Keypair, PublicKey } from "@solana/web3.js";
4+
import { BankrunProvider } from "anchor-bankrun";
5+
import { startAnchor } from "solana-bankrun";
6+
import type { AnchorProgramExample } from "../target/types/anchor_program_example";
7+
8+
import IDL from "../target/idl/anchor_program_example.json";
99
const PROGRAM_ID = new PublicKey(IDL.address);
1010

11-
describe('Account Data!', async () => {
12-
const context = await startAnchor('', [{ name: 'anchor_program_example', programId: PROGRAM_ID }], []);
11+
describe("Account Data!", async () => {
12+
const context = await startAnchor(
13+
"",
14+
[{ name: "anchor_program_example", programId: PROGRAM_ID }],
15+
[],
16+
);
1317
const provider = new BankrunProvider(context);
1418

1519
const payer = provider.wallet as anchor.Wallet;
@@ -18,20 +22,25 @@ describe('Account Data!', async () => {
1822
// Generate a new keypair for the addressInfo account
1923
const addressInfoAccount = new Keypair();
2024

21-
it('Create the address info account', async () => {
25+
it("Create the address info account", async () => {
2226
console.log(`Payer Address : ${payer.publicKey}`);
2327
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
2428

2529
// Instruction Ix data
2630
const addressInfo = {
27-
name: 'Joe C',
31+
name: "Joe C",
2832
houseNumber: 136,
29-
street: 'Mile High Dr.',
30-
city: 'Solana Beach',
33+
street: "Mile High Dr.",
34+
city: "Solana Beach",
3135
};
3236

3337
await program.methods
34-
.createAddressInfo(addressInfo.name, addressInfo.houseNumber, addressInfo.street, addressInfo.city)
38+
.createAddressInfo(
39+
addressInfo.name,
40+
addressInfo.houseNumber,
41+
addressInfo.street,
42+
addressInfo.city,
43+
)
3544
.accounts({
3645
addressInfo: addressInfoAccount.publicKey,
3746
payer: payer.publicKey,
@@ -41,7 +50,9 @@ describe('Account Data!', async () => {
4150
});
4251

4352
it("Read the new account's data", async () => {
44-
const addressInfo = await program.account.addressInfo.fetch(addressInfoAccount.publicKey);
53+
const addressInfo = await program.account.addressInfo.fetch(
54+
addressInfoAccount.publicKey,
55+
);
4556
console.log(`Name : ${addressInfo.name}`);
4657
console.log(`House Num: ${addressInfo.houseNumber}`);
4758
console.log(`Street : ${addressInfo.street}`);

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
import { describe, it } from 'node:test';
2-
import * as anchor from '@coral-xyz/anchor';
3-
import { Keypair, PublicKey, SystemProgram, Transaction } from '@solana/web3.js';
4-
import { BankrunProvider } from 'anchor-bankrun';
5-
import { startAnchor } from 'solana-bankrun';
6-
import type { AnchorProgramExample } from '../target/types/anchor_program_example';
7-
8-
import { IDL } from "../target/idl/anchor_program_example.json";
1+
import { describe, it } from "node:test";
2+
import * as anchor from "@coral-xyz/anchor";
3+
import {
4+
Keypair,
5+
PublicKey,
6+
SystemProgram,
7+
Transaction,
8+
} from "@solana/web3.js";
9+
import { BankrunProvider } from "anchor-bankrun";
10+
import { startAnchor } from "solana-bankrun";
11+
import type { AnchorProgramExample } from "../target/types/anchor_program_example";
12+
13+
import IDL from "../target/idl/anchor_program_example.json";
914
const PROGRAM_ID = new PublicKey(IDL.address);
1015

11-
describe('Bankrun example', async () => {
12-
const context = await startAnchor('', [{ name: 'anchor_program_example', programId: PROGRAM_ID }], []);
16+
describe("Bankrun example", async () => {
17+
const context = await startAnchor(
18+
"",
19+
[{ name: "anchor_program_example", programId: PROGRAM_ID }],
20+
[],
21+
);
1322
const provider = new BankrunProvider(context);
1423

1524
const wallet = provider.wallet as anchor.Wallet;
@@ -22,7 +31,7 @@ describe('Bankrun example', async () => {
2231
// Our program will create this.
2332
const accountToCreate = new Keypair();
2433

25-
it('Create an account owned by our program', async () => {
34+
it("Create an account owned by our program", async () => {
2635
const instruction = SystemProgram.createAccount({
2736
fromPubkey: provider.wallet.publicKey,
2837
newAccountPubkey: accountToChange.publicKey,
@@ -39,7 +48,7 @@ describe('Bankrun example', async () => {
3948
await client.processTransaction(transaction);
4049
});
4150

42-
it('Check accounts', async () => {
51+
it("Check accounts", async () => {
4352
await program.methods
4453
.checkAccounts()
4554
.accounts({

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

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
1-
import assert from 'node:assert';
2-
import { describe, it } from 'node:test';
3-
import * as anchor from '@coral-xyz/anchor';
4-
import { PublicKey } from '@solana/web3.js';
5-
import { BankrunProvider } from 'anchor-bankrun';
6-
import { startAnchor } from 'solana-bankrun';
7-
import type { CloseAccountProgram } from '../target/types/close_account_program';
1+
import assert from "node:assert";
2+
import { describe, it } from "node:test";
3+
import * as anchor from "@coral-xyz/anchor";
4+
import { PublicKey } from "@solana/web3.js";
5+
import { BankrunProvider } from "anchor-bankrun";
6+
import { startAnchor } from "solana-bankrun";
7+
import type { CloseAccountProgram } from "../target/types/close_account_program";
88

9-
import { IDL } from "../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

12-
describe('close-an-account', async () => {
12+
describe("close-an-account", async () => {
1313
// Configure the client to use the local cluster.
14-
const context = await startAnchor('', [{ name: 'close_account_program', programId: PROGRAM_ID }], []);
14+
const context = await startAnchor(
15+
"",
16+
[{ name: "close_account_program", programId: PROGRAM_ID }],
17+
[],
18+
);
1519
const provider = new BankrunProvider(context);
1620

1721
const payer = provider.wallet as anchor.Wallet;
1822
const program = new anchor.Program<CloseAccountProgram>(IDL, provider);
1923
// Derive the PDA for the user's account.
20-
const [userAccountAddress] = PublicKey.findProgramAddressSync([Buffer.from('USER'), payer.publicKey.toBuffer()], program.programId);
24+
const [userAccountAddress] = PublicKey.findProgramAddressSync(
25+
[Buffer.from("USER"), payer.publicKey.toBuffer()],
26+
program.programId,
27+
);
2128

22-
it('Create Account', async () => {
29+
it("Create Account", async () => {
2330
await program.methods
24-
.createUser('John Doe')
31+
.createUser("John Doe")
2532
.accounts({
2633
user: payer.publicKey,
2734
})
2835
.rpc();
2936

3037
// Fetch the account data
31-
const userAccount = await program.account.userState.fetch(userAccountAddress);
32-
assert.equal(userAccount.name, 'John Doe');
38+
const userAccount =
39+
await program.account.userState.fetch(userAccountAddress);
40+
assert.equal(userAccount.name, "John Doe");
3341
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
3442
});
3543

36-
it('Close Account', async () => {
44+
it("Close Account", async () => {
3745
await program.methods
3846
.closeUser()
3947
.accounts({
@@ -43,7 +51,8 @@ describe('close-an-account', async () => {
4351

4452
// The account should no longer exist, returning null.
4553
try {
46-
const userAccount = await program.account.userState.fetchNullable(userAccountAddress);
54+
const userAccount =
55+
await program.account.userState.fetchNullable(userAccountAddress);
4756
assert.equal(userAccount, null);
4857
} catch (err) {
4958
// Won't return null and will throw an error in anchor-bankrun'
Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import { describe, it } from 'node:test';
2-
import * as anchor from '@coral-xyz/anchor';
3-
import { Keypair, 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 { CounterAnchor } from '../target/types/counter_anchor';
8-
9-
import { IDL } from "../target/idl/counter_anchor.json";
1+
import { describe, it } from "node:test";
2+
import * as anchor from "@coral-xyz/anchor";
3+
import { Keypair, 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 { CounterAnchor } from "../target/types/counter_anchor";
8+
9+
import IDL from "../target/idl/counter_anchor.json";
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

12-
describe('counter_anchor', async () => {
12+
describe("counter_anchor", async () => {
1313
// Configure the client to use the anchor-bankrun
14-
const context = await startAnchor('', [{ name: 'counter_anchor', programId: PROGRAM_ID }], []);
14+
const context = await startAnchor(
15+
"",
16+
[{ name: "counter_anchor", programId: PROGRAM_ID }],
17+
[]
18+
);
1519
const provider = new BankrunProvider(context);
1620

1721
const payer = provider.wallet as anchor.Wallet;
@@ -20,7 +24,7 @@ describe('counter_anchor', async () => {
2024
// Generate a new keypair for the counter account
2125
const counterKeypair = new Keypair();
2226

23-
it('Initialize Counter', async () => {
27+
it("Initialize Counter", async () => {
2428
await program.methods
2529
.initializeCounter()
2630
.accounts({
@@ -30,16 +34,26 @@ describe('counter_anchor', async () => {
3034
.signers([counterKeypair])
3135
.rpc();
3236

33-
const currentCount = await program.account.counter.fetch(counterKeypair.publicKey);
37+
const currentCount = await program.account.counter.fetch(
38+
counterKeypair.publicKey
39+
);
3440

35-
assert(currentCount.count.toNumber() === 0, 'Expected initialized count to be 0');
41+
assert(
42+
currentCount.count.toNumber() === 0,
43+
"Expected initialized count to be 0"
44+
);
3645
});
3746

38-
it('Increment Counter', async () => {
39-
await program.methods.increment().accounts({ counter: counterKeypair.publicKey }).rpc();
47+
it("Increment Counter", async () => {
48+
await program.methods
49+
.increment()
50+
.accounts({ counter: counterKeypair.publicKey })
51+
.rpc();
4052

41-
const currentCount = await program.account.counter.fetch(counterKeypair.publicKey);
53+
const currentCount = await program.account.counter.fetch(
54+
counterKeypair.publicKey
55+
);
4256

43-
assert(currentCount.count.toNumber() === 1, 'Expected count to be 1');
57+
assert(currentCount.count.toNumber() === 1, "Expected count to be 1");
4458
});
4559
});

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
import { describe, it } from 'node:test';
2-
import * as anchor from '@coral-xyz/anchor';
3-
import { Keypair, 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 { CreateSystemAccount } from '../target/types/create_system_account';
1+
import { describe, it } from "node:test";
2+
import * as anchor from "@coral-xyz/anchor";
3+
import { Keypair, 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 { CreateSystemAccount } from "../target/types/create_system_account";
88

9-
import { IDL } from "../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

12-
describe('Create a system account', async () => {
13-
const context = await startAnchor('', [{ name: 'create_system_account', programId: PROGRAM_ID }], []);
12+
describe("Create a system account", async () => {
13+
const context = await startAnchor(
14+
"",
15+
[{ name: "create_system_account", programId: PROGRAM_ID }],
16+
[],
17+
);
1418
const provider = new BankrunProvider(context);
1519

1620
const wallet = provider.wallet as anchor.Wallet;
1721
const program = new anchor.Program<CreateSystemAccount>(IDL, provider);
1822
const connection = provider.connection;
1923

20-
it('Create the account', async () => {
24+
it("Create the account", async () => {
2125
// Generate a new keypair for the new account
2226
const newKeypair = new Keypair();
2327

0 commit comments

Comments
 (0)