|
@@ -1,6 +1,5 @@
|
|
const anchor = require("@project-serum/anchor");
|
|
const anchor = require("@project-serum/anchor");
|
|
const PublicKey = anchor.web3.PublicKey;
|
|
const PublicKey = anchor.web3.PublicKey;
|
|
-const serumCmn = require("@project-serum/common");
|
|
|
|
const assert = require("assert");
|
|
const assert = require("assert");
|
|
const { TOKEN_PROGRAM_ID, Token } = require("@solana/spl-token");
|
|
const { TOKEN_PROGRAM_ID, Token } = require("@solana/spl-token");
|
|
|
|
|
|
@@ -229,6 +228,54 @@ describe("misc", () => {
|
|
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ consumed 4819 of 200000 compute units",
|
|
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ consumed 4819 of 200000 compute units",
|
|
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ success",
|
|
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ success",
|
|
];
|
|
];
|
|
|
|
+
|
|
|
|
+ assert.ok(JSON.stringify(expectedRaw), resp.raw);
|
|
|
|
+ assert.ok(resp.events[0].name === "E1");
|
|
|
|
+ assert.ok(resp.events[0].data.data === 44);
|
|
|
|
+ assert.ok(resp.events[1].name === "E2");
|
|
|
|
+ assert.ok(resp.events[1].data.data === 1234);
|
|
|
|
+ assert.ok(resp.events[2].name === "E3");
|
|
|
|
+ assert.ok(resp.events[2].data.data === 9);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it("Can retrieve events when associated account is initialized in simulated transaction", async () => {
|
|
|
|
+ const myAccount = await program.account.testData.associatedAddress(
|
|
|
|
+ program.provider.wallet.publicKey
|
|
|
|
+ );
|
|
|
|
+ await assert.rejects(
|
|
|
|
+ async () => {
|
|
|
|
+ await program.account.testData.fetch(myAccount);
|
|
|
|
+ },
|
|
|
|
+ (err) => {
|
|
|
|
+ assert.ok(
|
|
|
|
+ err.toString() ===
|
|
|
|
+ `Error: Account does not exist ${myAccount.toString()}`
|
|
|
|
+ );
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const resp = await program.simulate.testSimulateAssociatedAccount(44, {
|
|
|
|
+ accounts: {
|
|
|
|
+ myAccount,
|
|
|
|
+ authority: program.provider.wallet.publicKey,
|
|
|
|
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
|
|
+ systemProgram: anchor.web3.SystemProgram.programId,
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ const expectedRaw = [
|
|
|
|
+ "Program Fv6oRfzWETatiMymBvTs1JpRspZz3DbBfjZJEvUTDL1g invoke [1]",
|
|
|
|
+ "Program 11111111111111111111111111111111 invoke [2]",
|
|
|
|
+ "Program 11111111111111111111111111111111 success",
|
|
|
|
+ "Program log: NgyCA9omwbMsAAAA",
|
|
|
|
+ "Program log: fPhuIELK/k7SBAAA",
|
|
|
|
+ "Program log: jvbowsvlmkcJAAAA",
|
|
|
|
+ "Program log: mg+zq/K0sXRV+N/AsG9XLERDZ+J6eQAnnzoQVHlicBQBnGr65KE5Kw==",
|
|
|
|
+ "Program Fv6oRfzWETatiMymBvTs1JpRspZz3DbBfjZJEvUTDL1g consumed 20460 of 200000 compute units",
|
|
|
|
+ "Program Fv6oRfzWETatiMymBvTs1JpRspZz3DbBfjZJEvUTDL1g success",
|
|
|
|
+ ];
|
|
|
|
+
|
|
assert.ok(JSON.stringify(expectedRaw), resp.raw);
|
|
assert.ok(JSON.stringify(expectedRaw), resp.raw);
|
|
assert.ok(resp.events[0].name === "E1");
|
|
assert.ok(resp.events[0].name === "E1");
|
|
assert.ok(resp.events[0].data.data === 44);
|
|
assert.ok(resp.events[0].data.data === 44);
|
|
@@ -236,6 +283,8 @@ describe("misc", () => {
|
|
assert.ok(resp.events[1].data.data === 1234);
|
|
assert.ok(resp.events[1].data.data === 1234);
|
|
assert.ok(resp.events[2].name === "E3");
|
|
assert.ok(resp.events[2].name === "E3");
|
|
assert.ok(resp.events[2].data.data === 9);
|
|
assert.ok(resp.events[2].data.data === 9);
|
|
|
|
+ assert.ok(resp.events[3].name === "E4");
|
|
|
|
+ assert.ok(resp.events[3].data.data.toBase58() === myAccount.toBase58());
|
|
});
|
|
});
|
|
|
|
|
|
it("Can use i8 in the idl", async () => {
|
|
it("Can use i8 in the idl", async () => {
|