Skip to content

Commit

Permalink
minor fixes (#492)
Browse files Browse the repository at this point in the history
* minor fixes

* fix test
  • Loading branch information
torztomasz committed Sep 21, 2023
1 parent c4e9730 commit 6fc8ce2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export class StateUpdateController {
l2Transactions,
] = await Promise.all([
this.stateUpdateRepository.findById(stateUpdateId),
this.preprocessedStateDetailsRepository.findById(stateUpdateId),
this.preprocessedStateDetailsRepository.findByStateUpdateId(
stateUpdateId
),
this.preprocessedAssetHistoryRepository.getByStateUpdateIdPaginated(
stateUpdateId,
paginationOpts
Expand Down
13 changes: 10 additions & 3 deletions packages/backend/src/core/preprocessing/Preprocessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe(Preprocessor.name, () => {
it('catches up', async () => {
const mockKnexTransaction = mockObject<Knex.Transaction>()
const lastPreprocessedStateUpdateId = 10
const preprocessL2TransactionTo = 5
const mockUserStatisticsPreprocessor =
mockObject<UserStatisticsPreprocessor>({
catchUp: mockFn().resolvesTo(undefined),
Expand Down Expand Up @@ -110,6 +111,12 @@ describe(Preprocessor.name, () => {
true
)

const mockGetStateUpdateIdToCatchUpL2TransactionsTo = mockFn().resolvesTo(
preprocessL2TransactionTo
)
preprocessor.getStateUpdateIdToCatchUpL2TransactionsTo =
mockGetStateUpdateIdToCatchUpL2TransactionsTo

await preprocessor.catchUp()

expect(
Expand All @@ -125,10 +132,10 @@ describe(Preprocessor.name, () => {
)
expect(
mockStateDetailsPreprocessor.catchUpL2Transactions
).toHaveBeenCalledWith(mockKnexTransaction, lastPreprocessedStateUpdateId)
expect(mockUserStatisticsPreprocessor.catchUp).toHaveBeenCalledWith(
).toHaveBeenCalledWith(mockKnexTransaction, preprocessL2TransactionTo)
expect(mockUserL2TransactionsPreprocessor.catchUp).toHaveBeenCalledWith(
mockKnexTransaction,
lastPreprocessedStateUpdateId
preprocessL2TransactionTo
)
})

Expand Down
10 changes: 8 additions & 2 deletions packages/backend/src/core/preprocessing/Preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,19 @@ export class Preprocessor<T extends AssetHash | AssetId> {
)

if (this.l2TransactionsEnabled) {
const preprocessL2TransactionTo =
await this.getStateUpdateIdToCatchUpL2TransactionsTo(
trx,
lastProcessedStateUpdate.stateUpdateId
)

await this.stateDetailsPreprocessor.catchUpL2Transactions(
trx,
lastProcessedStateUpdate.stateUpdateId
preprocessL2TransactionTo
)
await this.userL2TransactionsPreprocessor.catchUp(
trx,
lastProcessedStateUpdate.stateUpdateId
preprocessL2TransactionTo
)
}
}
Expand Down

0 comments on commit 6fc8ce2

Please sign in to comment.