idl-build-features.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { assert } from "chai";
  3. import { IdlBuildFeatures } from "../target/types/idl_build_features";
  4. describe("idl-build features", () => {
  5. anchor.setProvider(anchor.AnchorProvider.env());
  6. const program = anchor.workspace
  7. .idlBuildFeatures as anchor.Program<IdlBuildFeatures>;
  8. it("Can use full module path types", async () => {
  9. const kp = anchor.web3.Keypair.generate();
  10. const outerMyStructArg = { u8: 1, u16: 2, u32: 3, u64: new anchor.BN(4) };
  11. const someModuleMyStructArg = { data: 5 };
  12. await program.methods
  13. .fullPath(outerMyStructArg, someModuleMyStructArg)
  14. .accounts({ account: kp.publicKey })
  15. .preInstructions([
  16. await program.account.fullPathAccount.createInstruction(kp),
  17. ])
  18. .signers([kp])
  19. .rpc();
  20. const fullPathAccount = await program.account.fullPathAccount.fetch(
  21. kp.publicKey
  22. );
  23. assert.strictEqual(fullPathAccount.myStruct.u8, outerMyStructArg.u8);
  24. assert.strictEqual(fullPathAccount.myStruct.u16, outerMyStructArg.u16);
  25. assert.strictEqual(fullPathAccount.myStruct.u32, outerMyStructArg.u32);
  26. assert(fullPathAccount.myStruct.u64.eq(outerMyStructArg.u64));
  27. assert.deepEqual(fullPathAccount.someModuleMyStruct, someModuleMyStructArg);
  28. });
  29. });