test(session): preserve live binding after cancelled switches
This commit is contained in:
@@ -149,7 +149,7 @@ describe("target-bound provider routing", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("cancels a provider switch, closes its old client, and restores the binding", async () => {
|
||||
it("preserves the active client when a provider switch is cancelled while draining", async () => {
|
||||
const target = await databaseTarget();
|
||||
const alpha = deepProvider("alpha");
|
||||
const beta = deepProvider("beta");
|
||||
@@ -176,18 +176,18 @@ describe("target-bound provider routing", () => {
|
||||
ok: false,
|
||||
error: new AnalysisCancelledError("open_binary"),
|
||||
});
|
||||
expect(alpha.clients[0]?.closed).toBe(true);
|
||||
expect(alpha.clients[0]?.closed).toBe(false);
|
||||
expect(beta.clients).toHaveLength(0);
|
||||
expect(bindingStatus(session)).toMatchObject({
|
||||
analysis_provider_binding: { provider: { id: "alpha" } },
|
||||
});
|
||||
|
||||
alpha.pending = undefined;
|
||||
const restored = await session.execute("address_name", { address: "0x2" });
|
||||
expect(restored.ok && restored.value.provider.id).toBe("alpha");
|
||||
expect(alpha.clients).toHaveLength(2);
|
||||
const retained = await session.execute("address_name", { address: "0x2" });
|
||||
expect(retained.ok && retained.value.provider.id).toBe("alpha");
|
||||
expect(alpha.clients).toHaveLength(1);
|
||||
await session.close();
|
||||
expect(alpha.clients[1]?.closed).toBe(true);
|
||||
expect(alpha.clients[0]?.closed).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user