-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace noop with FinalizeRequest command
- Loading branch information
Showing
5 changed files
with
45 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
packages/automated-dispute/src/services/eboRegistry/commands/noop.ts
This file was deleted.
Oops, something went wrong.
63 changes: 40 additions & 23 deletions
63
packages/automated-dispute/tests/eboActor/onRequestFinalized.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,60 @@ | ||
import { ILogger } from "@ebo-agent/shared"; | ||
import { describe, expect, it, vi } from "vitest"; | ||
|
||
import { FinalizeRequest } from "../../src/services/index.js"; | ||
import { EboEvent } from "../../src/types/index.js"; | ||
import mocks from "../mocks/index.js"; | ||
import { DEFAULT_MOCKED_REQUEST_CREATED_DATA } from "./fixtures.js"; | ||
|
||
const logger: ILogger = mocks.mockLogger(); | ||
|
||
describe("EboActor", () => { | ||
describe("onRequestFinalized", () => { | ||
const actorRequest = DEFAULT_MOCKED_REQUEST_CREATED_DATA; | ||
|
||
const event: EboEvent<"RequestFinalized"> = { | ||
name: "RequestFinalized", | ||
requestId: actorRequest.id, | ||
blockNumber: 1n, | ||
logIndex: 1, | ||
metadata: { | ||
blockNumber: 1n, | ||
caller: "0x01", | ||
describe("processEvents", () => { | ||
describe("when RequestFinalized is enqueued", () => { | ||
const actorRequest = DEFAULT_MOCKED_REQUEST_CREATED_DATA; | ||
|
||
const event: EboEvent<"RequestFinalized"> = { | ||
name: "RequestFinalized", | ||
requestId: actorRequest.id, | ||
responseId: "0x02", | ||
}, | ||
}; | ||
blockNumber: 1n, | ||
logIndex: 1, | ||
metadata: { | ||
blockNumber: 1n, | ||
caller: "0x01", | ||
requestId: actorRequest.id, | ||
responseId: "0x02", | ||
}, | ||
}; | ||
|
||
it("logs a message during request finalization", async () => { | ||
const { actor, registry } = mocks.buildEboActor(actorRequest, logger); | ||
|
||
vi.spyOn(registry, "getRequest").mockReturnValue(actorRequest); | ||
|
||
const mockInfo = vi.spyOn(logger, "info"); | ||
|
||
actor.enqueue(event); | ||
|
||
await actor.processEvents(); | ||
|
||
expect(mockInfo).toHaveBeenCalledWith( | ||
expect.stringMatching(`Request ${actorRequest.id} has been finalized.`), | ||
); | ||
}); | ||
|
||
it("logs a message during request finalization", async () => { | ||
const { actor, registry } = mocks.buildEboActor(actorRequest, logger); | ||
it("uses the FinalizeRequest registry command", async () => { | ||
const { actor, registry } = mocks.buildEboActor(actorRequest, logger); | ||
|
||
vi.spyOn(registry, "getRequest").mockReturnValue(actorRequest); | ||
vi.spyOn(registry, "getRequest").mockReturnValue(actorRequest); | ||
|
||
const mockInfo = vi.spyOn(logger, "info"); | ||
const mockBuildFromEvent = vi.spyOn(FinalizeRequest, "buildFromEvent"); | ||
|
||
actor.enqueue(event); | ||
actor.enqueue(event); | ||
|
||
await actor.processEvents(); | ||
await actor.processEvents(); | ||
|
||
expect(mockInfo).toHaveBeenCalledWith( | ||
expect.stringMatching(`Request ${actorRequest.id} has been finalized.`), | ||
); | ||
expect(mockBuildFromEvent).toHaveBeenCalledWith(event, registry); | ||
}); | ||
}); | ||
}); | ||
}); |
24 changes: 0 additions & 24 deletions
24
packages/automated-dispute/tests/services/eboMemoryRegistry/commands/noop.spec.ts
This file was deleted.
Oops, something went wrong.