Skip to content

Commit

Permalink
fix: wait for confirmed status before fetch tx in test (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 authored Aug 14, 2024
1 parent 29f74b7 commit 28c1136
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 52 deletions.
18 changes: 10 additions & 8 deletions contracts/tests/ocr2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ describe("ocr2", () => {
schema: borsh.Schema,
classType: any
): Promise<any> => {
let tx = await workspace.Store.rpc.query(scope, {
accounts: { feed },
options: { commitment: "confirmed" },
});
let tx = await workspace.Store.methods
.query(scope)
.accounts({ feed })
.rpc();

await provider.connection.confirmTransaction(tx, "confirmed")
let t = await provider.connection.getTransaction(tx, {
commitment: "confirmed",
});
Expand Down Expand Up @@ -901,7 +903,7 @@ describe("ocr2", () => {
for (let i = 2; i <= rounds; i++) {
let transmitTx = await transmit(feed.publicKey, i, i, new BN(i));

await provider.connection.confirmTransaction(transmitTx);
await provider.connection.confirmTransaction(transmitTx, "confirmed");
let t = await provider.connection.getTransaction(transmitTx, {
commitment: "confirmed",
});
Expand Down Expand Up @@ -1011,7 +1013,7 @@ describe("ocr2", () => {
computePriceMicroLamports,
juelsPerLamport,
);
await provider.connection.confirmTransaction(tx);
await provider.connection.confirmTransaction(tx, "confirmed");
let t = await provider.connection.getTransaction(tx, { commitment: "confirmed" });
console.log(t.meta.logMessages); // 195_785/195_997
account = await program.account.state.fetch(state.publicKey, 'confirmed');
Expand Down Expand Up @@ -1155,7 +1157,7 @@ describe("ocr2", () => {
]
});
// Print out program log so we can see total units consumed
await provider.connection.confirmTransaction(tx);
await provider.connection.confirmTransaction(tx, "confirmed");
let t = await provider.connection.getTransaction(tx, {
commitment: "confirmed",
});
Expand Down Expand Up @@ -1280,7 +1282,7 @@ describe("ocr2", () => {

// submit, then read from the feed to ensure it works fine
let transmitTx = await transmit(feed.publicKey, 1, 1, new BN(100));
await provider.connection.confirmTransaction(transmitTx);
await provider.connection.confirmTransaction(transmitTx, "confirmed");
let t = await provider.connection.getTransaction(transmitTx, {
commitment: "confirmed",
});
Expand Down
Loading

0 comments on commit 28c1136

Please sign in to comment.