Skip to content

Commit

Permalink
tests: fix seemingly ok but actually broken tests (coral-xyz#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-schaaf authored Mar 20, 2022
1 parent deaa334 commit f0b4c38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion tests/chat/tests/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe("chat", () => {
assert.ok(msg.from.equals(user));
assert.ok(data.startsWith(messages[idx]));
} else {
assert.ok(anchor.web3.PublicKey.default);
assert.ok(
JSON.stringify(msg.data) === JSON.stringify(new Array(280).fill(0))
);
Expand Down
25 changes: 14 additions & 11 deletions tests/misc/tests/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,18 @@ describe("misc", () => {
it("Can retrieve events when simulating a transaction", async () => {
const resp = await program.simulate.testSimulate(44);
const expectedRaw = [
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ invoke [1]",
"Program log: NgyCA9omwbMsAAAA",
"Program log: fPhuIELK/k7SBAAA",
"Program log: jvbowsvlmkcJAAAA",
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ consumed 4819 of 200000 compute units",
"Program Z2Ddx1Lcd8CHTV9tkWtNnFQrSz6kxz2H38wrr18zZRZ success",
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS invoke [1]",
"Program log: Instruction: TestSimulate",
"Program data: NgyCA9omwbMsAAAA",
"Program data: fPhuIELK/k7SBAAA",
"Program data: jvbowsvlmkcJAAAA",
"Program data: zxM5neEnS1kBAgMEBQYHCAkK",
"Program data: g06Ei2GL1gIBAgMEBQYHCAkKCw==",
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS consumed 5320 of 200000 compute units",
"Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS success",
];

assert.ok(JSON.stringify(expectedRaw), resp.raw);
assert.deepStrictEqual(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");
Expand Down Expand Up @@ -328,7 +331,7 @@ describe("misc", () => {

const myPdaAccount = await program.account.dataZeroCopy.fetch(myPda);
assert.ok(myPdaAccount.data === 9);
assert.ok((myPdaAccount.bump = nonce));
assert.ok(myPdaAccount.bump === nonce);
});

it("Can write to a zero copy PDA account", async () => {
Expand All @@ -345,7 +348,7 @@ describe("misc", () => {

const myPdaAccount = await program.account.dataZeroCopy.fetch(myPda);
assert.ok(myPdaAccount.data === 1234);
assert.ok((myPdaAccount.bump = bump));
assert.ok(myPdaAccount.bump === bump);
});

it("Can create a token account from seeds pda", async () => {
Expand Down Expand Up @@ -887,7 +890,7 @@ describe("misc", () => {
signers: [ifNeededAcc],
});
const account = await program.account.dataU16.fetch(ifNeededAcc.publicKey);
assert.ok(account.data, 1);
assert.equal(account.data, 1);
});

it("Can init if needed a previously created account", async () => {
Expand All @@ -900,7 +903,7 @@ describe("misc", () => {
signers: [ifNeededAcc],
});
const account = await program.account.dataU16.fetch(ifNeededAcc.publicKey);
assert.ok(account.data, 3);
assert.equal(account.data, 3);
});

it("Can use const for array size", async () => {
Expand Down

0 comments on commit f0b4c38

Please sign in to comment.