Skip to content

Commit 699b6be

Browse files
committed
lint with prettier
1 parent c7d9c92 commit 699b6be

File tree

3 files changed

+107
-105
lines changed

3 files changed

+107
-105
lines changed

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

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,54 @@ const IDL = require("../target/idl/close_account_program.json");
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

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

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

29-
it("Create Account", async () => {
30-
await program.methods
31-
.createUser()
32-
.accounts({
33-
user: payer.publicKey,
34-
})
35-
.rpc();
29+
it("Create Account", async () => {
30+
await program.methods
31+
.createUser()
32+
.accounts({
33+
user: payer.publicKey,
34+
})
35+
.rpc();
3636

37-
// Fetch the account data
38-
const userAccount =
39-
await program.account.closeAccountState.fetch(userAccountAddress);
40-
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
41-
});
37+
// Fetch the account data
38+
const userAccount = await program.account.closeAccountState.fetch(
39+
userAccountAddress
40+
);
41+
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
42+
});
4243

43-
it("Close Account", async () => {
44-
await program.methods
45-
.closeUser()
46-
.accounts({
47-
user: payer.publicKey,
48-
})
49-
.rpc();
44+
it("Close Account", async () => {
45+
await program.methods
46+
.closeUser()
47+
.accounts({
48+
user: payer.publicKey,
49+
})
50+
.rpc();
5051

51-
// The account should no longer exist, returning null.
52-
try {
53-
const userAccount =
54-
await program.account.closeAccountState.fetchNullable(
55-
userAccountAddress,
56-
);
57-
assert.equal(userAccount, null);
58-
} catch (err) {
59-
// Won't return null and will throw an error in anchor-bankrun'
60-
assert.equal(err.message, `Could not find ${userAccountAddress}`);
61-
}
62-
});
52+
// The account should no longer exist, returning null.
53+
try {
54+
const userAccount = await program.account.closeAccountState.fetchNullable(
55+
userAccountAddress
56+
);
57+
assert.equal(userAccount, null);
58+
} catch (err) {
59+
// Won't return null and will throw an error in anchor-bankrun'
60+
assert.equal(err.message, `Could not find ${userAccountAddress}`);
61+
}
62+
});
6363
});

basics/close-account/poseidon/tests/test.ts

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,50 @@ import { PublicKey } from "@solana/web3.js";
55
import { CloseAccountProgram } from "../target/types/close_account_program";
66

77
describe("close_account", () => {
8-
// Configure the client to use the local cluster.
9-
10-
const provider = anchor.AnchorProvider.env();
11-
anchor.setProvider(provider);
12-
13-
const program = anchor.workspace
14-
.CloseAccountProgram as Program<CloseAccountProgram>;
15-
const payer = provider.wallet as anchor.Wallet;
16-
17-
// Derive the PDA for the user's account.
18-
const [userAccountAddress] = PublicKey.findProgramAddressSync(
19-
[Buffer.from("user"), payer.publicKey.toBuffer()],
20-
program.programId,
21-
);
22-
23-
it("Create Account", async () => {
24-
await program.methods
25-
.createUser()
26-
.accounts({
27-
user: payer.publicKey,
28-
userAccount: userAccountAddress,
29-
})
30-
.rpc();
31-
32-
// Fetch the account data
33-
const userAccount =
34-
await program.account.closeAccountState.fetch(userAccountAddress);
35-
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
36-
});
37-
38-
it("Close Account", async () => {
39-
await program.methods
40-
.closeUser()
41-
.accounts({
42-
user: payer.publicKey,
43-
userAccount: userAccountAddress,
44-
})
45-
.rpc();
46-
47-
// The account should no longer exist, returning null.
48-
const userAccount =
49-
await program.account.closeAccountState.fetchNullable(userAccountAddress);
50-
assert.equal(userAccount, null);
51-
});
8+
// Configure the client to use the local cluster.
9+
10+
const provider = anchor.AnchorProvider.env();
11+
anchor.setProvider(provider);
12+
13+
const program = anchor.workspace
14+
.CloseAccountProgram as Program<CloseAccountProgram>;
15+
const payer = provider.wallet as anchor.Wallet;
16+
17+
// Derive the PDA for the user's account.
18+
const [userAccountAddress] = PublicKey.findProgramAddressSync(
19+
[Buffer.from("user"), payer.publicKey.toBuffer()],
20+
program.programId
21+
);
22+
23+
it("Create Account", async () => {
24+
await program.methods
25+
.createUser()
26+
.accounts({
27+
user: payer.publicKey,
28+
userAccount: userAccountAddress,
29+
})
30+
.rpc();
31+
32+
// Fetch the account data
33+
const userAccount = await program.account.closeAccountState.fetch(
34+
userAccountAddress
35+
);
36+
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
37+
});
38+
39+
it("Close Account", async () => {
40+
await program.methods
41+
.closeUser()
42+
.accounts({
43+
user: payer.publicKey,
44+
userAccount: userAccountAddress,
45+
})
46+
.rpc();
47+
48+
// The account should no longer exist, returning null.
49+
const userAccount = await program.account.closeAccountState.fetchNullable(
50+
userAccountAddress
51+
);
52+
assert.equal(userAccount, null);
53+
});
5254
});
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { Account, Pubkey, Result, u8, Signer } from "@solanaturbine/poseidon";
22

33
export default class closeAccountProgram {
4-
static PROGRAM_ID = new Pubkey(
5-
"7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd",
6-
);
4+
static PROGRAM_ID = new Pubkey(
5+
"7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd"
6+
);
77

8-
// create user account
8+
// create user account
99

10-
create_user(user_account: closeAccountState, user: Signer): Result {
11-
user_account.derive(["user", user.key]).init();
10+
create_user(user_account: closeAccountState, user: Signer): Result {
11+
user_account.derive(["user", user.key]).init();
1212

13-
// Set the initial value to the `user_account` fields
14-
user_account.user = user.key;
15-
user_account.bump = user_account.getBump();
16-
}
13+
// Set the initial value to the `user_account` fields
14+
user_account.user = user.key;
15+
user_account.bump = user_account.getBump();
16+
}
1717

18-
// close user account
18+
// close user account
1919

20-
close_user(user_account: closeAccountState, user: Signer): Result {
21-
user_account.close(user);
22-
}
20+
close_user(user_account: closeAccountState, user: Signer): Result {
21+
user_account.close(user);
22+
}
2323
}
2424

2525
// setup the state
2626

2727
export interface closeAccountState extends Account {
28-
user: Pubkey; // This field store the user pub key
29-
bump: u8; // bump is for PDA (program derieved account, a special type of account which controlled by program on Solana)
28+
user: Pubkey; // This field store the user pub key
29+
bump: u8; // bump is for PDA (program derieved account, a special type of account which controlled by program on Solana)
3030
}

0 commit comments

Comments
 (0)