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