import { type Graph } from 'graph/index.js'; import { type KeysetWithSecrets } from 'keyset/index.js'; import { type SyncMessage, type SyncState } from 'sync/types.js'; import { type UserWithSecrets } from 'user/index.js'; /** Simulates a peer-to-peer network. */ export declare class Network { peers: Record; queue: NetworkMessage[]; keys: KeysetWithSecrets; constructor(keys: KeysetWithSecrets); registerPeer(peer: Peer): void; /** Establishes a bidirectionial connection between two peers */ connect(a: Peer, b: Peer): void; /** Enqueues one message to be sent from fromPeer to toPeer */ sendMessage(from: string, to: string, body: SyncMessage): void; /** Runs the protocol until all peers run out of things to say */ deliverAll(): NetworkMessage[]; } /** One peer, which may be connected to any number of other peers */ export declare class Peer { userName: string; graph: Graph; network: Network; syncStates: Record; constructor(userName: string, graph: Graph, network: Network); /** Called by Network.connect when a connection is established with a remote peer */ connect(userName: string): void; /** Generates and enqueues messages to the named peer (or if none given, to all peers we're connected to) (unless there is nothing to send) */ sync(userName?: string): void; /** Called by Network when we receive a message from another peer */ receiveMessage(sender: string, message: SyncMessage): void; } export declare const setupWithNetwork: (keys: KeysetWithSecrets) => (...userNames: string[]) => { userRecords: Record; network: Network; founder: TestUserStuff; }; export declare const expectToBeSynced: (a: TestUserStuff, b: TestUserStuff) => void; export declare const expectNotToBeSynced: (a: TestUserStuff, b: TestUserStuff) => void; export type NetworkMessage = { to: string; from: string; body: SyncMessage; }; export type TestUserStuff = { user: UserWithSecrets; peer: Peer; }; //# sourceMappingURL=Network.d.ts.map