Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions impl/src/clear.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@ const siteTable: readonly SiteTableEntry[] = [
},
];

async function setupImpressions(config?: TestConfig): Promise<Backend> {
function setupImpressions(config?: TestConfig): Backend {
const backend = makeBackend(config);
await Promise.all(
siteTable.map(({ impression, conversion: conversionSites }) =>
backend.saveImpression(impression, undefined, {
histogramIndex: 1,
conversionSites,
}),
),
);
for (const entry of siteTable) {
backend.saveImpression(entry.impression, undefined, {
histogramIndex: 1,
conversionSites: entry.conversion,
});
}
return backend;
}

// Clearing state for a given site only affects available privacy budget.
void test("clear-site-state", async () => {
const backend = await setupImpressions();
void test("clear-site-state", () => {
const backend = setupImpressions();

// Check that this rejects correctly.
assert.throws(() => backend.clearState([], false));
Expand Down Expand Up @@ -83,9 +81,9 @@ void test("clear-site-state", async () => {
});

// Forgetting all sites resets the entire thing, except the last reset time.
void test("forget-all-sites", async () => {
void test("forget-all-sites", () => {
const now = Temporal.Instant.from("2025-01-01T00:00Z");
const backend = await setupImpressions({ now, ...defaultConfig });
const backend = setupImpressions({ now, ...defaultConfig });
backend.clearState([], true);

assert.deepEqual(backend.impressions, []);
Expand All @@ -95,9 +93,9 @@ void test("forget-all-sites", async () => {
});

// Forgetting a site with impressions removes impressions.
void test("forget-one-site-impressions", async () => {
void test("forget-one-site-impressions", () => {
const now = Temporal.Instant.from("2025-01-01T00:00Z");
const backend = await setupImpressions({ now, ...defaultConfig });
const backend = setupImpressions({ now, ...defaultConfig });
backend.clearState(["imp-one.example"], true);

assert.deepEqual(
Expand All @@ -111,9 +109,9 @@ void test("forget-one-site-impressions", async () => {
});

// Forgetting a site with conversion state removes those.
void test("forget-one-site-conversions", async () => {
void test("forget-one-site-conversions", () => {
const now = Temporal.Instant.from("2025-01-01T00:00Z");
const backend = await setupImpressions({ now, ...defaultConfig });
const backend = setupImpressions({ now, ...defaultConfig });

const before = backend.measureConversion("conv-one.example", undefined, {
aggregationService: Object.keys(defaultConfig.aggregationServices)[0]!,
Expand Down