You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packages/builder/test/unit/utils/apiStub.ts (added in #9781) largely duplicates packages/validator/test/utils/apiStub.ts. Per discussion on #9781, the shared parts should be deduped into packages/test-utils as a follow-up so the two don't drift.
Comparing the two, it's a bit more than a 1:1 dup — a few things need reconciling:
mockApiResponse — identical in both; trivially shareable.
getApiClientStub — function lists differ. Builder stubs only beacon.getStateBuilders + node.getSyncingStatus; validator stubs a much larger beacon/node/validator set plus httpClient. Note the builder adds beacon.getStateBuilders, which the validator stub doesn't have. A shared helper would need to expose a superset or be parameterized so each consumer only stubs the endpoints it needs.
httpClientStub + httpClient field — present in validator, omitted in builder.
ApiClientStub type — exported in builder, local in validator.
Suggested approach
Move the shared pieces (the ApiClientStub type, mockApiResponse, mockApiErrorResponse, and a base getApiClientStub / httpClientStub) into packages/test-utils, and have both the builder and validator suites import from there, stubbing package-specific endpoints on top as needed.
Not urgent — filing so it isn't lost after #9781 merges.
Follow-up from #9781.
packages/builder/test/unit/utils/apiStub.ts(added in #9781) largely duplicatespackages/validator/test/utils/apiStub.ts. Per discussion on #9781, the shared parts should be deduped intopackages/test-utilsas a follow-up so the two don't drift.Current state
packages/builder/test/unit/utils/apiStub.ts(on the feat(builder): add readiness gating and builder identity resolution #9781 branch)packages/validator/test/utils/apiStub.ts(unstable)Comparing the two, it's a bit more than a 1:1 dup — a few things need reconciling:
mockApiResponse— identical in both; trivially shareable.getApiClientStub— function lists differ. Builder stubs onlybeacon.getStateBuilders+node.getSyncingStatus; validator stubs a much larger beacon/node/validator set plushttpClient. Note the builder addsbeacon.getStateBuilders, which the validator stub doesn't have. A shared helper would need to expose a superset or be parameterized so each consumer only stubs the endpoints it needs.mockApiErrorResponse— already aligned onunstable: the validator version isasync+await res.errorBody()there. (An earlier revision of this issue flagged it as diverged, but that compared against the feat(builder): add readiness gating and builder identity resolution #9781 branch snapshot, which predates that change — thanks @markolazic01.) Once feat(builder): add readiness gating and builder identity resolution #9781 is on top ofunstable, both are identical, so no reconciliation needed here.httpClientStub+httpClientfield — present in validator, omitted in builder.ApiClientStubtype — exported in builder, local in validator.Suggested approach
Move the shared pieces (the
ApiClientStubtype,mockApiResponse,mockApiErrorResponse, and a basegetApiClientStub/httpClientStub) intopackages/test-utils, and have both the builder and validator suites import from there, stubbing package-specific endpoints on top as needed.Not urgent — filing so it isn't lost after #9781 merges.
Refs: #9781, #9781 (comment)