Skip to content

Commit

Permalink
fix: trival fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yanCode committed Dec 21, 2024
1 parent a18c83e commit 7dbe334
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
10 changes: 7 additions & 3 deletions tests/anchor-cli-account/tests/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Test CLI account commands", () => {
await program.methods
.initialize(
balance,
new anchor.BN(amount),
amount,
memo,
values.map((x) => new anchor.BN(x))
)
Expand Down Expand Up @@ -52,7 +52,11 @@ describe("Test CLI account commands", () => {
}
}

assert.strictEqual(output.balance, balance, "Balance deserialized incorrectly");
assert.strictEqual(
output.balance,
balance,
"Balance deserialized incorrectly"
);
assert.strictEqual(
output.delegate_pubkey,
provider.wallet.publicKey.toBase58(),
Expand All @@ -69,7 +73,7 @@ describe("Test CLI account commands", () => {
"Memo deserialized incorrectly"
);
for (let i = 0; i < values.length; i++) {
assert.strictEqual(
assert.equal(
output.sub.values[i],
values[i],
"Values deserialized incorrectly"
Expand Down
9 changes: 6 additions & 3 deletions tests/cpi-returns/tests/cpi-return.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ describe("CPI return", () => {

const cpiReturn = anchor.web3.Keypair.generate();

const confirmOptions: ConfirmOptions = { commitment: "confirmed" };
const confirmOptions: ConfirmOptions = {
commitment: "confirmed",
maxRetries: 5,
};

it("can initialize", async () => {
await calleeProgram.methods
Expand All @@ -45,7 +48,7 @@ describe("CPI return", () => {
it("can return u64 from a cpi", async () => {
const tx = await callerProgram.methods
.cpiCallReturnU64()
.accounts({
.accountsPartial({
cpiReturn: cpiReturn.publicKey,
cpiReturnProgram: calleeProgram.programId,
})
Expand Down Expand Up @@ -134,7 +137,7 @@ describe("CPI return", () => {
});

const [key, data, buffer] = getReturnLog(t);
assert.strictEqual(key, calleeProgram.programId);
assert.strictEqual(key, calleeProgram.programId.toBase58());

// Check for matching log on receive side
let receiveLog = t.meta.logMessages.find(
Expand Down
11 changes: 5 additions & 6 deletions tests/misc/tests/misc/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ const miscTest = (
],
});
const account = await getAccount(connection, token.publicKey);
// @ts-expect-error
// assert.strictEqual(account.state, 1);
assert.strictEqual(account.amount, BigInt(0));
assert.isTrue(account.isInitialized);
Expand Down Expand Up @@ -781,7 +780,7 @@ const miscTest = (

const tx = await program.methods
.testCompositePayer()
.accounts({
.accountsPartial({
composite: {
data: data1.publicKey,
payer: provider.wallet.publicKey,
Expand Down Expand Up @@ -849,7 +848,7 @@ const miscTest = (
);
const ataAccount = AccountLayout.decode(rawAccount.data);
assert.strictEqual(ataAccount.state, 1);
assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0);
assert.strictEqual(ataAccount.amount, BigInt(0));
assert.strictEqual(
new PublicKey(ataAccount.owner).toString(),
provider.wallet.publicKey.toString()
Expand Down Expand Up @@ -933,7 +932,7 @@ const miscTest = (
);
const ataAccount = AccountLayout.decode(rawAta.data);
assert.strictEqual(ataAccount.state, 1);
assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0);
assert.strictEqual(ataAccount.amount, BigInt(0));
assert.strictEqual(
new PublicKey(ataAccount.owner).toString(),
provider.wallet.publicKey.toString()
Expand Down Expand Up @@ -1482,7 +1481,7 @@ const miscTest = (
newToken.publicKey
);
const ataAccount = AccountLayout.decode(rawAccount.data);
assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0);
assert.strictEqual(ataAccount.amount, BigInt(0));
assert.strictEqual(
new PublicKey(ataAccount.mint).toString(),
newMint.publicKey.toString()
Expand Down Expand Up @@ -1581,7 +1580,7 @@ const miscTest = (
associatedToken
);
const ataAccount = AccountLayout.decode(rawAccount.data);
assert.strictEqual(new anchor.BN(ataAccount.amount).toNumber(), 0);
assert.strictEqual(ataAccount.amount, BigInt(0));
assert.strictEqual(
new PublicKey(ataAccount.mint).toString(),
newMint.publicKey.toString()
Expand Down
10 changes: 5 additions & 5 deletions tests/realloc/tests/realloc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("realloc", () => {
it("initialized", async () => {
await program.methods
.initialize()
.accounts({ authority: authority.publicKey, sample })
.accountsPartial({ authority: authority.publicKey, sample })
.rpc();

const samples = await program.account.sample.all();
Expand All @@ -35,7 +35,7 @@ describe("realloc", () => {
try {
await program.methods
.realloc(10250)
.accounts({ authority: authority.publicKey, sample })
.accountsPartial({ authority: authority.publicKey, sample })
.rpc();
assert.ok(false);
} catch (e) {
Expand All @@ -51,7 +51,7 @@ describe("realloc", () => {
it("realloc additive", async () => {
await program.methods
.realloc(5)
.accounts({ authority: authority.publicKey, sample })
.accountsPartial({ authority: authority.publicKey, sample })
.rpc();

const s = await program.account.sample.fetch(sample);
Expand All @@ -61,7 +61,7 @@ describe("realloc", () => {
it("realloc substractive", async () => {
await program.methods
.realloc(1)
.accounts({ authority: authority.publicKey, sample })
.accountsPartial({ authority: authority.publicKey, sample })
.rpc();

const s = await program.account.sample.fetch(sample);
Expand All @@ -72,7 +72,7 @@ describe("realloc", () => {
try {
await program.methods
.realloc2(1000)
.accounts({
.accountsPartial({
authority: authority.publicKey,
sample1: sample,
sample2: sample,
Expand Down

0 comments on commit 7dbe334

Please sign in to comment.