Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/code/classes/testing.TransactionLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/testing/fixtures/algorand-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/testing/transaction-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ export class TransactionLogger {
return new Proxy<Algodv2>(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())
}
}

Expand Down
Loading