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 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()) } }