misc.js 862 B

123456789101112131415161718192021222324252627
  1. const anchor = require('@project-serum/anchor');
  2. const assert = require("assert");
  3. describe("misc", () => {
  4. // Configure the client to use the local cluster.
  5. anchor.setProvider(anchor.Provider.env());
  6. it("Can use u128 and i128", async () => {
  7. const data = new anchor.web3.Account();
  8. const program = anchor.workspace.Misc;
  9. const tx = await program.rpc.initialize(
  10. new anchor.BN(1234),
  11. new anchor.BN(22),
  12. {
  13. accounts: {
  14. data: data.publicKey,
  15. rent: anchor.web3.SYSVAR_RENT_PUBKEY,
  16. },
  17. signers: [data],
  18. instructions: [await program.account.data.createInstruction(data)],
  19. }
  20. );
  21. const dataAccount = await program.account.data(data.publicKey);
  22. assert.ok(dataAccount.udata.eq(new anchor.BN(1234)));
  23. assert.ok(dataAccount.idata.eq(new anchor.BN(22)));
  24. });
  25. });