From 8636988f9965e83b586a01b59d008ee57380710e Mon Sep 17 00:00:00 2001 From: Joe Polny Date: Mon, 16 Dec 2024 14:46:51 -0500 Subject: [PATCH 1/2] fix: waitForIndexer waiting for transactions that failed --- src/testing/fixtures/algorand-fixture.ts | 2 +- src/testing/transaction-logger.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/testing/fixtures/algorand-fixture.ts b/src/testing/fixtures/algorand-fixture.ts index b57bacba..5026ddb5 100644 --- a/src/testing/fixtures/algorand-fixture.ts +++ b/src/testing/fixtures/algorand-fixture.ts @@ -111,7 +111,7 @@ export function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: return account }, transactionLogger: transactionLogger, - waitForIndexer: () => transactionLogger.waitForIndexer(indexer), + waitForIndexer: () => transactionLogger.waitForIndexer(algod, indexer), waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(transactionId).do()), } } diff --git a/src/testing/transaction-logger.ts b/src/testing/transaction-logger.ts index 2011b65d..40340bcc 100644 --- a/src/testing/transaction-logger.ts +++ b/src/testing/transaction-logger.ts @@ -49,9 +49,10 @@ export class TransactionLogger { return new Proxy(algod, new TransactionLoggingAlgodv2ProxyHandler(this)) } - /** Wait until all logged transactions IDs appear in the given `Indexer`. */ - async waitForIndexer(indexer: Indexer) { - await Promise.all(this._sentTransactionIds.map((txnId) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do()))) + /** Wait until indexer has the last round from algod. */ + async waitForIndexer(algod: Algodv2, indexer: Indexer) { + const round = (await algod.status().do()).lastRound + await runWhenIndexerCaughtUp(() => indexer.lookupBlock(round).do()) } } From a5d9ecf3474d2fe30abd3842017462dd18b4d85a Mon Sep 17 00:00:00 2001 From: Joe Polny Date: Mon, 16 Dec 2024 14:54:52 -0500 Subject: [PATCH 2/2] run typedoc --- docs/code/classes/testing.TransactionLogger.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/code/classes/testing.TransactionLogger.md b/docs/code/classes/testing.TransactionLogger.md index 785d7e39..bd8dc221 100644 --- a/docs/code/classes/testing.TransactionLogger.md +++ b/docs/code/classes/testing.TransactionLogger.md @@ -130,14 +130,15 @@ ___ ### waitForIndexer -▸ **waitForIndexer**(`indexer`): `Promise`\<`void`\> +▸ **waitForIndexer**(`algod`, `indexer`): `Promise`\<`void`\> -Wait until all logged transactions IDs appear in the given `Indexer`. +Wait until indexer has the last round from algod. #### Parameters | Name | Type | | :------ | :------ | +| `algod` | `AlgodClient` | | `indexer` | `IndexerClient` | #### Returns