import { RoochClient } from '@roochnetwork/rooch-sdk';
import { K as KeyType, x as KeyManager, S as SignerInterface, z as IdentityEnv, h as VDRRegistry } from '../IdentityKit-DE2ZpFFA.js';
import { R as RoochVDR } from '../roochVDR-Cax3bJc-.js';
import { ChildProcess } from 'child_process';

/**
 * Options for bootstrapping test environment
 */
interface TestEnvOptions {
    /** Rooch RPC endpoint URL, defaults to ROOCH_NODE_URL env var or http://localhost:6767 */
    rpcUrl?: string;
    /** Network type */
    network?: 'local' | 'dev' | 'test' | 'main';
    /** Auto start local node if RPC URL is not accessible (useful for CI) */
    autoStartLocalNode?: boolean;
    /** Amount to fund new accounts via faucet */
    faucetAmount?: bigint;
    /** Enable debug logging */
    debug?: boolean;
}
/**
 * Result of creating a self-managed DID
 */
interface CreateSelfDidResult {
    /** The created DID string */
    did: string;
    /** The VM ID fragment associated with this DID */
    vmIdFragment: string;
    /** KeyManager with the account key imported */
    keyManager: KeyManager;
    /** Signer interface for this DID */
    signer: SignerInterface;
    /** Pre-configured IdentityEnv for this DID (convenient for Payment Kit integration) */
    identityEnv: IdentityEnv;
}
/**
 * Options for creating a self-managed DID
 */
interface CreateSelfDidOptions {
    /** Key type to use for the account key */
    keyType?: KeyType;
    secretKey?: string;
    /** Custom fragment for the account key */
    keyFragment?: string;
    /** Skip funding the account (useful if account already has funds) */
    skipFunding?: boolean;
    /** Custom session key scopes (for Rooch VDR) */
    customScopes?: string[];
}
/**
 * Options for creating a CADOP DID scenario
 */
interface CreateCadopDidOptions {
    /** Key type for the user's did:key */
    userKeyType?: KeyType;
    /** Key type for the custodian's service key */
    custodianKeyType?: KeyType;
    /** Skip funding accounts */
    skipFunding?: boolean;
}
/**
 * Environment check result
 */
interface EnvironmentCheck {
    /** Whether tests should be skipped */
    shouldSkip: boolean;
    /** Reason for skipping (if any) */
    reason?: string;
    /** Available RPC URL */
    rpcUrl?: string;
}
/**
 * Options for starting a local Rooch node
 */
interface RoochNodeOptions {
    /** Rooch binary path, defaults to ROOCH_E2E_BIN environment variable */
    binaryPath?: string;
    /** Port number, defaults to auto-allocate starting from 6767 */
    port?: number;
    /** Data directory, defaults to temp directory */
    dataDir?: string;
    /** Logs directory, defaults to temp directory */
    logsDir?: string;
    /** Additional server arguments */
    serverArgs?: string[];
    /** Network type */
    network?: 'local' | 'dev' | 'test' | 'main';
    /** Enable debug logging */
    debug?: boolean;
}
/**
 * Handle representing a running Rooch node
 */
interface RoochNodeHandle {
    /** RPC URL for connecting to the node */
    rpcUrl: string;
    /** Port number the node is listening on */
    port: number;
    /** Process ID of the node */
    pid: number;
    /** Data directory path */
    dataDir: string;
    /** Logs directory path */
    logsDir: string;
    /** Stop the node and cleanup resources */
    stop(): Promise<void>;
    /** Check if the node is still running */
    isRunning(): boolean;
}

/**
 * Test environment for Rooch DID integration testing
 *
 * Provides a pre-configured environment with:
 * - Rooch client and VDR registry
 * - Helper methods for creating test identities
 *
 * Note: Each createSelfDid() call returns its own dedicated IdentityEnv,
 * which is preferred for multi-party testing scenarios to avoid conflicts.
 */
declare class TestEnv$1 {
    private static instance?;
    private logger;
    readonly rpcUrl: string;
    readonly network: string;
    readonly client: RoochClient;
    readonly vdrRegistry: VDRRegistry;
    readonly roochVDR: RoochVDR;
    private constructor();
    /**
     * Bootstrap test environment
     */
    static bootstrap(options?: TestEnvOptions): Promise<TestEnv$1>;
    /**
     * Check if integration tests should be skipped
     */
    static skipIfNoNode(): boolean;
    /**
     * Synchronous environment check
     */
    static checkEnvironmentSync(): EnvironmentCheck;
    /**
     * Async environment check with RPC connectivity test
     */
    static checkEnvironment(options: Required<TestEnvOptions>): Promise<EnvironmentCheck>;
    /**
     * Resolve options with defaults
     */
    private static resolveOptions;
    /**
     * Fund an account via faucet (placeholder for future implementation)
     */
    fundAccount(address: string, amount?: bigint): Promise<void>;
}

/**
 * Utility functions for Rooch testing
 */
declare const RoochTestUtils: {
    /**
     * Check if we should skip integration tests
     */
    shouldSkip(): boolean;
    /**
     * Get environment check result
     */
    checkEnvironment(): any;
};
/**
 * Convenience function to bootstrap a Rooch test environment
 * This is an alias for TestEnv.bootstrap() for backward compatibility
 */
declare function bootstrapRoochTestEnv(options?: any): Promise<TestEnv$1>;

interface TestEnv {
    rpcUrl: string;
    network: string;
    vdrRegistry: any;
    roochVDR: any;
    fundAccount(address: string, amount?: bigint): Promise<void>;
}
/**
 * Create a self-managed DID by calling the on-chain create_did_object_for_self function
 */
declare function createSelfDid(env: TestEnv, options?: CreateSelfDidOptions): Promise<CreateSelfDidResult>;
/**
 * Create a custodian DID with CADOP service
 */
declare function createCadopCustodian(env: TestEnv, options?: Pick<CreateCadopDidOptions, 'custodianKeyType' | 'skipFunding'>): Promise<CreateSelfDidResult>;
/**
 * Create a user DID via CADOP protocol using an existing custodian
 */
declare function createDidViaCadop(env: TestEnv, custodian: CreateSelfDidResult, options?: Pick<CreateCadopDidOptions, 'userKeyType'>): Promise<CreateSelfDidResult>;

/**
 * Rooch Local Node Manager
 *
 * Provides lightweight local Rooch node management for testing scenarios.
 * Uses only Node.js built-in modules without external dependencies.
 */
declare class RoochLocalNode {
    /**
     * Start a local Rooch node
     *
     * @param opts Configuration options
     * @returns Handle to the running node
     */
    static start(opts?: RoochNodeOptions): Promise<RoochNodeHandle>;
    /**
     * Ensure a Rooch node is ready by checking chain ID
     *
     * @param rpcUrl RPC URL of the node
     * @param child Optional child process to check for exit
     * @param timeout Timeout in milliseconds
     */
    static ensureReady(rpcUrl: string, child?: ChildProcess, timeout?: number): Promise<void>;
    /**
     * Initialize Rooch configuration in a directory
     *
     * @param binaryPath Path to rooch binary
     * @param configDir Directory to initialize config in
     */
    private static initializeConfig;
    /**
     * Find an available port starting from the given port
     *
     * @param startPort Starting port number
     * @returns Available port number
     */
    static findAvailablePort(startPort?: number): Promise<number>;
    /**
     * Check if a port is available
     *
     * @param port Port number to check
     * @returns True if port is available
     */
    static isPortAvailable(port: number): Promise<boolean>;
    /**
     * Stop a running node with cleanup
     *
     * @param child Child process to stop
     * @param port Port number to cleanup
     * @param dataDir Data directory to cleanup
     * @param logsDir Logs directory to cleanup
     */
    private static stop;
    /**
     * Check if a process is running
     *
     * @param pid Process ID
     * @returns True if process is running
     */
    private static isRunning;
    /**
     * Wait for a port to be released
     *
     * @param port Port number
     * @param maxWait Maximum wait time in milliseconds
     */
    private static waitForPortRelease;
}
/**
 * Convenience function to start a local Rooch node
 *
 * @param opts Configuration options
 * @returns Handle to the running node
 */
declare function startLocalRoochNode(opts?: RoochNodeOptions): Promise<RoochNodeHandle>;
/**
 * Convenience function to check if a Rooch node is ready
 *
 * @param rpcUrl RPC URL of the node
 * @param timeout Timeout in milliseconds
 */
declare function ensureRoochReady(rpcUrl: string, timeout?: number): Promise<void>;

export { type CreateCadopDidOptions, type CreateSelfDidOptions, type CreateSelfDidResult, type EnvironmentCheck, RoochLocalNode, type RoochNodeHandle, type RoochNodeOptions, RoochTestUtils, TestEnv$1 as TestEnv, type TestEnvOptions, bootstrapRoochTestEnv, createCadopCustodian, createDidViaCadop, createSelfDid, ensureRoochReady, startLocalRoochNode };
