Skip to content

Instantly share code, notes, and snippets.

@0xPratik
Created April 9, 2022 17:14
Show Gist options
  • Save 0xPratik/28c2f2e364e4c16534c9bfa269199c9a to your computer and use it in GitHub Desktop.
Save 0xPratik/28c2f2e364e4c16534c9bfa269199c9a to your computer and use it in GitHub Desktop.
import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { Brianxyz } from "../target/types/brianxyz";
describe("brianxyz", () => {
// Configure the client to use the local cluster.
anchor.setProvider(anchor.Provider.env());
const program = anchor.workspace.Brianxyz as Program<Brianxyz>;
// it("Is initialized!", async () => {
// // Add your test here.
// console.log("Program", program.programId.toString());
// console.log("SYSTEM", anchor.web3.SystemProgram.programId.toString());
// const [vote, _votebump] = await anchor.web3.PublicKey.findProgramAddress(
// [Buffer.from("vote_account")],
// program.programId
// );
// console.log("Vote Account", vote.toString());
// const tx = await program.rpc.initialize({
// accounts: {
// voteAccount: vote,
// user: program.provider.wallet.publicKey,
// systemProgram: anchor.web3.SystemProgram.programId,
// },
// });
// console.log("Your transaction signature", tx);
// });
// it("Should Vote SuperMan", async () => {
// const [vote, _votebump] = await anchor.web3.PublicKey.findProgramAddress(
// [Buffer.from("vote_account")],
// program.programId
// );
// console.log("Vote Account in SuperMan", vote.toString());
// const tx = await program.rpc.voteSuperMan({
// accounts: {
// voteAccount: vote,
// },
// });
// console.log("Your transaction signature", tx);
// });
// it("Should Vote IronMan", async () => {
// const [vote, _votebump] = await anchor.web3.PublicKey.findProgramAddress(
// [Buffer.from("vote_account")],
// program.programId
// );
// console.log("Vote Account in IronMan", vote.toString());
// const tx = await program.rpc.voteIronMan({
// accounts: {
// voteAccount: vote,
// },
// });
// console.log("Your transaction signature", tx);
// });
it("Should read Data from Vote Account", async () => {
const [vote, _votebump] = await anchor.web3.PublicKey.findProgramAddress(
[Buffer.from("vote_account")],
program.programId
);
const data = await program.account.voteAccount.fetch(vote);
console.log("SuperMan", data.superMan.toNumber());
console.log("IronMan", data.ironMan.toNumber());
console.log(data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment