|
@@ -10,9 +10,18 @@ describe("declare-program", () => {
|
|
anchor.workspace.declareProgram;
|
|
anchor.workspace.declareProgram;
|
|
const externalProgram: anchor.Program<External> = anchor.workspace.external;
|
|
const externalProgram: anchor.Program<External> = anchor.workspace.external;
|
|
|
|
|
|
- it("Can CPI", async () => {
|
|
|
|
- const { pubkeys } = await externalProgram.methods.init().rpcAndKeys();
|
|
|
|
|
|
+ // TODO: Add a utility type that does this?
|
|
|
|
+ let pubkeys: Awaited<
|
|
|
|
+ ReturnType<
|
|
|
|
+ ReturnType<typeof externalProgram["methods"]["init"]>["rpcAndKeys"]
|
|
|
|
+ >
|
|
|
|
+ >["pubkeys"];
|
|
|
|
+
|
|
|
|
+ before(async () => {
|
|
|
|
+ pubkeys = (await externalProgram.methods.init().rpcAndKeys()).pubkeys;
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ it("Can CPI", async () => {
|
|
const value = 5;
|
|
const value = 5;
|
|
await program.methods
|
|
await program.methods
|
|
.cpi(value)
|
|
.cpi(value)
|
|
@@ -24,4 +33,17 @@ describe("declare-program", () => {
|
|
);
|
|
);
|
|
assert.strictEqual(myAccount.field, value);
|
|
assert.strictEqual(myAccount.field, value);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ it("Can CPI composite", async () => {
|
|
|
|
+ const value = 3;
|
|
|
|
+ await program.methods
|
|
|
|
+ .cpiComposite(value)
|
|
|
|
+ .accounts({ cpiMyAccount: pubkeys.myAccount })
|
|
|
|
+ .rpc();
|
|
|
|
+
|
|
|
|
+ const myAccount = await externalProgram.account.myAccount.fetch(
|
|
|
|
+ pubkeys.myAccount
|
|
|
|
+ );
|
|
|
|
+ assert.strictEqual(myAccount.field, value);
|
|
|
|
+ });
|
|
});
|
|
});
|