misc.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const anchor = require("@project-serum/anchor");
  2. const serumCmn = require("@project-serum/common");
  3. const assert = require("assert");
  4. describe("misc", () => {
  5. // Configure the client to use the local cluster.
  6. anchor.setProvider(anchor.Provider.env());
  7. it("Can use u128 and i128", async () => {
  8. const data = new anchor.web3.Account();
  9. const program = anchor.workspace.Misc;
  10. const tx = await program.rpc.initialize(
  11. new anchor.BN(1234),
  12. new anchor.BN(22),
  13. {
  14. accounts: {
  15. data: data.publicKey,
  16. rent: anchor.web3.SYSVAR_RENT_PUBKEY,
  17. },
  18. signers: [data],
  19. instructions: [await program.account.data.createInstruction(data)],
  20. }
  21. );
  22. const dataAccount = await program.account.data(data.publicKey);
  23. assert.ok(dataAccount.udata.eq(new anchor.BN(1234)));
  24. assert.ok(dataAccount.idata.eq(new anchor.BN(22)));
  25. });
  26. it("Can embed programs into genesis from the Anchor.toml", async () => {
  27. const pid = new anchor.web3.PublicKey(
  28. "FtMNMKp9DZHKWUyVAsj3Q5QV8ow4P3fUPP7ZrWEQJzKr"
  29. );
  30. let accInfo = await anchor.getProvider().connection.getAccountInfo(pid);
  31. assert.ok(accInfo.executable);
  32. });
  33. });