Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 17, 2024
1 parent 1ddcf8d commit 36d3b9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export class SimulatorOracle implements DBOracle {

// We compute the number of consecutive empty logs we found and repeat the process if we haven't found enough.
numConsecutiveEmptyLogs = WINDOW_SIZE - indexOfLastLog - 1;
} while (numConsecutiveEmptyLogs >= MIN_CONSECUTIVE_EMPTY_LOGS);
} while (numConsecutiveEmptyLogs < MIN_CONSECUTIVE_EMPTY_LOGS);

const contractName = await this.contractDataOracle.getDebugContractName(contractAddress);
if (currentIndex !== oldIndex) {
Expand Down
11 changes: 6 additions & 5 deletions yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,13 @@ describe('Simulator oracle', () => {
let indexesAsSenderAfterSync = await database.getTaggingSecretsIndexesAsSender(secrets);
expect(indexesAsSenderAfterSync).toStrictEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]);

// Two windows are fetch for each sender
expect(aztecNode.getLogsByTags.mock.calls.length).toBe(NUM_SENDERS * 2);
// Only 1 window is obtained for each sender
expect(aztecNode.getLogsByTags.mock.calls.length).toBe(NUM_SENDERS);
aztecNode.getLogsByTags.mockReset();

// We add more logs at the end of the window to make sure we only detect them and bump the indexes if it lies within our window
senderOffset = 10;
// We add more logs to the second half of the window to test that a second iteration in `syncTaggedLogsAsSender`
// is handled correctly.
senderOffset = 11;
generateMockLogs(senderOffset);
for (let i = 0; i < senders.length; i++) {
await simulatorOracle.syncTaggedLogsAsSender(
Expand All @@ -308,7 +309,7 @@ describe('Simulator oracle', () => {
}

indexesAsSenderAfterSync = await database.getTaggingSecretsIndexesAsSender(secrets);
expect(indexesAsSenderAfterSync).toStrictEqual([11, 11, 11, 11, 11, 12, 12, 12, 12, 12]);
expect(indexesAsSenderAfterSync).toStrictEqual([12, 12, 12, 12, 12, 13, 13, 13, 13, 13]);

expect(aztecNode.getLogsByTags.mock.calls.length).toBe(NUM_SENDERS * 2);
});
Expand Down

0 comments on commit 36d3b9f

Please sign in to comment.