Skip to content

Commit de24c9c

Browse files
committed
fix: test
1 parent ee8b218 commit de24c9c

File tree

3 files changed

+19
-39
lines changed

3 files changed

+19
-39
lines changed

packages/data-flow/test/integration/strategy.integration.spec.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -209,30 +209,14 @@ describe("Orchestrator Integration - Strategy Events Processing", () => {
209209
"fetchEventsByBlockNumberAndLogIndex",
210210
);
211211

212-
const mockDistribution = {
213-
matchingDistribution: [
214-
{
215-
contributionsCount: 44,
216-
projectPayoutAddress: "0x7340F1a1e4e38F43d2FCC85cdb2b764de36B40c0",
217-
applicationId: "3",
218-
matchPoolPercentage: 0.099999,
219-
projectId: "0x15c5e4db5530e05216abc9484025e2f1c4fb55b8525d29ef38fde237e767e324",
220-
projectName: "ReFi DAO - A Network Society to Regenerate Earth. ✨ 🌱",
221-
matchAmountInToken: "999999999999999475712",
222-
originalMatchAmountInToken: "999999999999999475712",
223-
},
224-
{
225-
contributionsCount: 69,
226-
projectPayoutAddress: "0x01d1909cA27E364904934849eab8399532dd5c8b",
227-
applicationId: "11",
228-
matchPoolPercentage: 0.099999,
229-
projectId: "0xca460772f5ba0840a589d2c19fb7e17ac259e4be884313e3712c06c9c885dc93",
230-
projectName: "Giveth",
231-
matchAmountInToken: "999999999999999475712",
232-
originalMatchAmountInToken: "999999999999999475712",
233-
},
234-
],
235-
};
212+
const mockDistribution = [
213+
{
214+
anchorAddress: "0x7340F1a1e4e38F43d2FCC85cdb2b764de36B40c0",
215+
payoutAddress: "0x7340F1a1e4e38F43d2FCC85cdb2b764de36B40c0",
216+
amount: "1000000000000000000",
217+
index: 0,
218+
}
219+
];
236220

237221
vi.spyOn(metadataProvider, "getMetadata").mockResolvedValue(mockDistribution);
238222

@@ -254,7 +238,7 @@ describe("Orchestrator Integration - Strategy Events Processing", () => {
254238
{ chainId, strategyAddress: distributionUpdatedEvent.srcAddress },
255239
{
256240
readyForPayoutTransaction: distributionUpdatedEvent.transactionFields.hash,
257-
matchingDistribution: mockDistribution.matchingDistribution,
241+
matchingDistribution: mockDistribution,
258242
},
259243
{},
260244
);

packages/processors/test/strategy/easyRetroFunding/easyRetroFunding.handler.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import { ChainId, ILogger, ProcessorEvent, StrategyEvent } from "@grants-stack-i
1212

1313
import { UnsupportedEventException } from "../../../src/internal.js";
1414
import {
15-
BaseDistributionUpdatedHandler,
1615
BaseFundsDistributedHandler,
1716
BaseRecipientStatusUpdatedHandler,
1817
} from "../../../src/processors/strategy/common/index.js";
1918
import { EasyRetroFundingStrategyHandler } from "../../../src/processors/strategy/easyRetroFunding/easyRetroFunding.handler.js";
2019
import {
20+
ERFDistributionUpdatedHandler,
2121
ERFRegisteredHandler,
2222
ERFTimestampsUpdatedHandler,
2323
ERFUpdatedRegistrationHandler,
@@ -27,38 +27,37 @@ vi.mock("../../../src/processors/strategy/easyRetroFunding/handlers/index.js", a
2727
const ERFRegisteredHandler = vi.fn();
2828
const ERFTimestampsUpdatedHandler = vi.fn();
2929
const ERFUpdatedRegistrationHandler = vi.fn();
30-
30+
const ERFDistributionUpdatedHandler = vi.fn();
3131
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3232
ERFRegisteredHandler.prototype.handle = vi.fn();
3333
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3434
ERFTimestampsUpdatedHandler.prototype.handle = vi.fn();
3535
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3636
ERFUpdatedRegistrationHandler.prototype.handle = vi.fn();
3737
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
38+
ERFDistributionUpdatedHandler.prototype.handle = vi.fn();
39+
3840
return {
3941
ERFRegisteredHandler,
4042
ERFTimestampsUpdatedHandler,
4143
ERFUpdatedRegistrationHandler,
44+
ERFDistributionUpdatedHandler,
4245
};
4346
});
4447

4548
vi.mock("../../../src/processors/strategy/common/index.js", async (importOriginal) => {
4649
const original =
4750
await importOriginal<typeof import("../../../src/processors/strategy/common/index.js")>();
4851
const BaseFundsDistributedHandler = vi.fn();
49-
const BaseDistributionUpdatedHandler = vi.fn();
5052
const BaseRecipientStatusUpdatedHandler = vi.fn();
5153

5254
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5355
BaseFundsDistributedHandler.prototype.handle = vi.fn();
5456
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
55-
BaseDistributionUpdatedHandler.prototype.handle = vi.fn();
56-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5757
BaseRecipientStatusUpdatedHandler.prototype.handle = vi.fn();
5858
return {
5959
...original,
6060
BaseFundsDistributedHandler,
61-
BaseDistributionUpdatedHandler,
6261
BaseRecipientStatusUpdatedHandler,
6362
};
6463
});
@@ -197,16 +196,16 @@ describe("EasyRetroFundingStrategyHandler", () => {
197196
expect(ERFTimestampsUpdatedHandler.prototype.handle).toHaveBeenCalled();
198197
});
199198

200-
it("calls BaseDistributionUpdatedHandler for DistributionUpdated event", async () => {
199+
it("calls ERFDistributionUpdatedHandler for DistributionUpdated event", async () => {
201200
const mockEvent = {
202201
eventName: "DistributionUpdated",
203202
} as ProcessorEvent<"Strategy", "DistributionUpdated">;
204203

205-
vi.spyOn(BaseDistributionUpdatedHandler.prototype, "handle").mockResolvedValue([]);
204+
vi.spyOn(ERFDistributionUpdatedHandler.prototype, "handle").mockResolvedValue([]);
206205

207206
await handler.handle(mockEvent);
208207

209-
expect(BaseDistributionUpdatedHandler).toHaveBeenCalledWith(mockEvent, chainId, {
208+
expect(ERFDistributionUpdatedHandler).toHaveBeenCalledWith(mockEvent, chainId, {
210209
metadataProvider: mockMetadataProvider,
211210
roundRepository: mockRoundRepository,
212211
projectRepository: mockProjectRepository,
@@ -215,7 +214,7 @@ describe("EasyRetroFundingStrategyHandler", () => {
215214
applicationRepository: mockApplicationRepository,
216215
logger,
217216
});
218-
expect(BaseDistributionUpdatedHandler.prototype.handle).toHaveBeenCalled();
217+
expect(ERFDistributionUpdatedHandler.prototype.handle).toHaveBeenCalled();
219218
});
220219

221220
it("calls FundsDistributedHandler for FundsDistributed event", async () => {

packages/processors/test/strategy/easyRetroFunding/handlers/distributionUpdated.handler.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,8 @@ describe("ERFDistributionUpdatedHandler", () => {
111111

112112
it("handles empty matching distribution array", async () => {
113113
mockEvent = createMockEvent(eventName, defaultParams, defaultStrategyId);
114-
const emptyDistribution = {
115-
matchingDistribution: [],
116-
};
117114

118-
vi.spyOn(mockMetadataProvider, "getMetadata").mockResolvedValue(emptyDistribution);
115+
vi.spyOn(mockMetadataProvider, "getMetadata").mockResolvedValue([]);
119116

120117
handler = new ERFDistributionUpdatedHandler(mockEvent, chainId, {
121118
metadataProvider: mockMetadataProvider,

0 commit comments

Comments
 (0)