diff --git a/src/keeper/Event.ts b/src/keeper/Event.ts index f4c59ee..39d9401 100644 --- a/src/keeper/Event.ts +++ b/src/keeper/Event.ts @@ -4,7 +4,7 @@ import Web3Provider from "./Web3Provider" export default class Event { - private poller + private poller = null private lastBlock: number = 0 private interval: number = 200 @@ -15,7 +15,8 @@ export default class Event { } public stopListen() { - clearTimeout(this.poller) + clearInterval(this.poller) + this.poller = null } public async listen(callback: any) { diff --git a/test/keeper/Event.test.ts b/test/keeper/Event.test.ts index eadbe19..a0f06a7 100644 --- a/test/keeper/Event.test.ts +++ b/test/keeper/Event.test.ts @@ -41,6 +41,7 @@ describe("EventListener", () => { assert(events) assert(events.length === 2) done() + EventListener.unsubscribe(event) }) const {market} = keeper diff --git a/test/keeper/EventListener.test.ts b/test/keeper/EventListener.test.ts index 3634595..bc3eb88 100644 --- a/test/keeper/EventListener.test.ts +++ b/test/keeper/EventListener.test.ts @@ -41,6 +41,7 @@ describe("EventListener", () => { const countAfter = EventListener.count() assert(countBefore + 1 === countAfter, `${countBefore}${countAfter}`) + EventListener.unsubscribe(event) done() }) })