
      import { Temporal } from "@js-temporal/polyfill";
      import { URLPattern } from "urlpattern-polyfill";
      globalThis.addEventListener = () => {};
    
import "../lookup-Csp1y88W.js";
import { AssertionError, assertEquals } from "../assert_equals-DSbWqCm3.js";
import { createExponentialBackoffPolicy } from "../retry-CfF8Gn4d.js";
import { test } from "../testing-YUoSZp2V.js";
import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";

//#region src/federation/retry.test.ts
test("createExponentialBackoffPolicy()", () => {
	const policy = createExponentialBackoffPolicy({ maxAttempts: 4 });
	const noMatter = Temporal.Duration.from({ seconds: 0 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 0
	}), { seconds: 1 }, { seconds: 2 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 1
	}), { seconds: 2 }, { seconds: 4 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 2
	}), { seconds: 4 }, { seconds: 8 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 3
	}), { seconds: 8 }, { seconds: 16 });
	assertEquals(policy({
		elapsedTime: noMatter,
		attempts: 4
	}), null);
});
function assertDurationRange(actual, min, max) {
	assertNotEquals(actual, null);
	if (actual == null) return;
	const minDuration = Temporal.Duration.from(min);
	const maxDuration = Temporal.Duration.from(max);
	if (Temporal.Duration.compare(actual, minDuration) < 0 || Temporal.Duration.compare(actual, maxDuration) > 0) throw new AssertionError(`Expected ${actual} to be between ${min} and ${max}`);
}

//#endregion