Skip to content

Commit a1f0743

Browse files
Otter-0x4ka5hAkash Thota
andauthored
fix: Flaky test#3980 (#3987)
* fix: add maxretries to send trasactions * prettier * chore(retry): add skippreflight is true * Re-run CI * fix: optional tests * empty work fow * revert optional tests --------- Co-authored-by: Akash Thota <your.email@example.com>
1 parent 7360dbb commit a1f0743

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

tests/auction-house/tests/auction-house.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ describe("auction-house", () => {
112112
mintAuthority: authority,
113113
}
114114
);
115-
await getProvider().sendAndConfirm(tx);
115+
await getProvider().sendAndConfirm(tx, [], {
116+
maxRetries: 3,
117+
skipPreflight: true,
118+
});
116119
});
117120

118121
it("Creates token accounts for the NFT", async () => {
@@ -184,7 +187,10 @@ describe("auction-house", () => {
184187
lamports: 100 * 10 ** 9,
185188
})
186189
);
187-
const txSig = await getProvider().sendAndConfirm(tx);
190+
const txSig = await getProvider().sendAndConfirm(tx, [], {
191+
maxRetries: 3,
192+
skipPreflight: true,
193+
});
188194
console.log("fund buyer:", txSig);
189195
});
190196

@@ -421,7 +427,10 @@ describe("auction-house", () => {
421427
.instruction()
422428
);
423429

424-
const txSig = await authorityClient.provider.sendAndConfirm(tx);
430+
const txSig = await authorityClient.provider.sendAndConfirm(tx, [], {
431+
maxRetries: 3,
432+
skipPreflight: true,
433+
});
425434
console.log("updateAuctionHouse:", txSig);
426435

427436
const newAh = await authorityClient.account.auctionHouse.fetch(

tests/bench/tests/compute-units.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ describe("Compute units", () => {
141141
.instruction();
142142
tx.add(createTokenIx, initTokenIx);
143143

144-
await tokenProgram.provider.sendAndConfirm!(tx, [mintKp, tokenKp]);
144+
await tokenProgram.provider.sendAndConfirm!(tx, [mintKp, tokenKp], {
145+
maxRetries: 3,
146+
skipPreflight: true,
147+
});
145148
});
146149

147150
it("AccountInfo", async () => {

tests/cpi-returns/tests/cpi-return.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ describe("CPI return", () => {
2828

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

31-
const confirmOptions: ConfirmOptions = { commitment: "confirmed" };
31+
const confirmOptions: ConfirmOptions = {
32+
commitment: "confirmed",
33+
preflightCommitment: "confirmed",
34+
skipPreflight: true,
35+
maxRetries: 3,
36+
};
3237

3338
it("can initialize", async () => {
3439
await calleeProgram.methods

tests/custom-discriminator/tests/custom-discriminator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ describe("custom-discriminator", () => {
1919
assert(data.equals(Buffer.from(ix.discriminator)));
2020

2121
// Verify tx runs
22-
await program.provider.sendAndConfirm!(tx);
22+
await program.provider.sendAndConfirm!(tx, [], {
23+
maxRetries: 3,
24+
skipPreflight: true,
25+
});
2326
};
2427

2528
it("Integer", () => testCommon("int"));

tests/errors/tests/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe("errors", () => {
4646
// because we cannot get logs for them (only through overkill `onLogs`)
4747
provider.opts.commitment = "confirmed";
4848
anchor.setProvider(provider);
49+
provider.opts.maxRetries = 3;
4950

5051
const program = anchor.workspace.Errors as Program<Errors>;
5152

tests/events/tests/events.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ describe("Events", () => {
4646
});
4747

4848
describe("CPI event", () => {
49+
const config = {
50+
commitment: "confirmed",
51+
preflightCommitment: "confirmed",
52+
skipPreflight: true,
53+
maxRetries: 3,
54+
} as const;
55+
4956
it("Works without accounts being specified", async () => {
5057
const tx = await program.methods.testEventCpi().transaction();
51-
const config = { commitment: "confirmed" } as const;
5258
const txHash = await program.provider.sendAndConfirm(tx, [], config);
5359
const txResult = await program.provider.connection.getTransaction(
5460
txHash,
@@ -91,7 +97,7 @@ describe("Events", () => {
9197
);
9298

9399
try {
94-
await program.provider.sendAndConfirm(tx, []);
100+
await program.provider.sendAndConfirm(tx, [], config);
95101
} catch (e) {
96102
if (e.logs.some((log) => log.includes("ConstraintSigner"))) return;
97103
console.log(e);

tests/spl/transfer-hook/tests/transfer-hook.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ describe("transfer hook", () => {
136136
"confirmed"
137137
);
138138

139-
await sendAndConfirmTransaction(provider.connection, transaction, [
140-
payer,
141-
mint,
142-
mintAuthority,
143-
]);
139+
await sendAndConfirmTransaction(
140+
provider.connection,
141+
transaction,
142+
[payer, mint, mintAuthority],
143+
{ maxRetries: 3, skipPreflight: true }
144+
);
144145
});
145146

146147
it("can create an `InitializeExtraAccountMetaList` instruction with the proper discriminator", async () => {
@@ -275,7 +276,8 @@ describe("transfer hook", () => {
275276
await sendAndConfirmTransaction(
276277
provider.connection,
277278
new Transaction().add(ix),
278-
[payer, sourceAuthority]
279+
[payer, sourceAuthority],
280+
{ maxRetries: 3, skipPreflight: true }
279281
);
280282

281283
// Check the resulting token balances

0 commit comments

Comments
 (0)