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

0 comments on commit 2fd058a

Please sign in to comment.