Skip to content

Commit

Permalink
fix event poller
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Aug 29, 2024
1 parent 6e9c168 commit d582466
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/events/eventsPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export class EventPoller extends EventEmitter {
try {
if (this.lastSlot) {
this.eventsFilter.start = nextSlot(this.lastSlot)
} else {
this.lastSlot = this.eventsFilter.start || nextSlot(this.lastSlot)
}

const events = await this.provider.getEvents(this.eventsFilter)
Expand Down
26 changes: 26 additions & 0 deletions test/integration/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,30 @@ describe('SC Event tests', () => {
})
stopPolling()
})

test('poll transfer event without start slot', async () => {
const amount = 1_000n

const operation = await usdcContract.transfer(
'AU1wN8rn4SkwYSTDF3dHFY4U28KtsqKL1NnEjDZhHnHEy6cEQm53',
amount
)
await operation.waitSpeculativeExecution()

let events: SCEvent[] = []

const filter: EventFilter = {
operationId: operation.id,
}

const { stopPolling } = EventPoller.start(provider, filter, (data) => {
events = data
})

await waitForExpect(() => {
expect(events.length).toEqual(1)
expect(events[0].data).toEqual('TRANSFER SUCCESS')
})
stopPolling()
})
})

1 comment on commit d582466

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for experimental massa-web3

St.
Category Percentage Covered / Total
🟡 Statements 63.15% 1109/1756
🔴 Branches 43.79% 187/427
🔴 Functions 46.4% 206/444
🟡 Lines 63.46% 1103/1738

Test suite run success

129 tests passing in 13 suites.

Report generated by 🧪jest coverage report action from d582466

Please sign in to comment.