/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { EnvMap } from '../../src/env.js'; import type { Store } from '../../src/ports.js'; import type { MemoryLedger } from '../../src/adapters/memory.js'; /** * Holds one engine wired for adversarial testing. The `store` is a live {@link Store} whose clean * setup goes through the app. The `raw` field is an escape hatch onto the same tables, used to * write the violation around the app. The `close` field tears the namespace down. The provisioner * returns `null` instead of this interface when the engine is unreachable. */ export interface AdversarialEngine { name: string; store: Store; raw(sql: string, params?: unknown[]): Promise; close(): Promise; } export interface AdversarialMemory { name: 'memory'; store: Store; ledger: MemoryLedger; close(): Promise; } /** * Builds the memory oracle for adversarial setup. Memory is always available. The returned `ledger` * is the concrete {@link MemoryLedger}, which exposes `append` and the `__`-prefixed back doors the * cases use to write around `postEntry`. */ export declare function adversarialMemory(): AdversarialMemory; /** * Provisions Postgres for adversarial testing, or returns `null` if unreachable. Creates a * throwaway schema and points both the store's pool and our raw pool at it via search_path, so a * raw INSERT lands in the very table `post_entry` writes. Mirrors postgresStore's own isolation. */ export declare function adversarialPostgres(env: EnvMap): Promise; /** * Provisions MySQL for adversarial testing, or returns `null` if unreachable (for example, when * MYSQL_TEST_URL is unset). * * Each call gets a throwaway database, the MySQL analogue of Postgres's throwaway schema. This * serves two purposes. First, it isolates this run from test/adapters/mysql.test.ts, which shares * the same server. Second, because conservation is enforced by a restricted role that lacks `legs` * DML, it gives that role a database of its own to be GRANTed on. The admin connection applies the * schema, so post_entry's DEFINER is privileged and stays the sole writer of `legs`. The store and * raw pools then connect as the restricted role, and the database is dropped on close. Both pools * point at it, so a raw INSERT lands in the very table post_entry writes, except `legs`, which the * restricted role cannot write directly. */ export declare function adversarialMysql(env: EnvMap): Promise; /** * Provisions the SQL engines wired for adversarial testing. Each provisioner returns `null` when * its engine is unreachable. Callers skip those rather than fail, so the suite is green with zero, * one, or both engines live. */ export declare function adversarialSqlEngines(env: EnvMap): Promise>;