-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfa63f3
commit d02dcda
Showing
2 changed files
with
63 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { Program } from "@coral-xyz/anchor"; | ||
import { Vault } from "../target/types/vault"; | ||
import { PublicKey, SystemProgram } from "@solana/web3.js"; | ||
import { expect } from "chai"; | ||
|
||
describe("vault", () => { | ||
// Configure the client to use the local cluster. | ||
anchor.setProvider(anchor.AnchorProvider.env()); | ||
|
||
const program = anchor.workspace.Vault as Program<Vault>; | ||
const provider = anchor.getProvider() as anchor.AnchorProvider; | ||
const wallet = provider.wallet; | ||
|
||
let vaultState: PublicKey; | ||
let vault: PublicKey; | ||
let vaultBump: number; | ||
let stateBump: number; | ||
|
||
it("Is initialized!", async () => { | ||
// Add your test here. | ||
const tx = await program.methods.initialize().rpc(); | ||
console.log("Your transaction signature", tx); | ||
[vaultState, stateBump] = await PublicKey.findProgramAddressSync( | ||
[Buffer.from("state"), wallet.publicKey.toBuffer()], | ||
program.programId | ||
); | ||
[vault, vaultBump] = await PublicKey.findProgramAddressSync( | ||
[vaultState.toBuffer()], | ||
program.programId | ||
); | ||
const tx = await program.methods | ||
.initialize() | ||
.accounts({ | ||
signer: wallet.publicKey, | ||
}).rpc(); | ||
console.log("Initialized vault. Transaction signature:", tx); | ||
|
||
const vaultStateAccount = await program.account.vaultState.fetch(vaultState); | ||
|
||
expect(vaultStateAccount.vaultBump).to.equal(vaultBump); | ||
expect(vaultStateAccount.stateBump).to.equal(stateBump); | ||
}); | ||
}); |