/// import { Server } from "../../../server"; import { PermanentProver } from "../../../app/modules/prover/lib/permanentProver"; import { BlockDTO } from "../../../app/lib/dto/BlockDTO"; import * as stream from "stream"; import { RevocationDTO } from "../../../app/lib/dto/RevocationDTO"; import { IdentityDTO } from "../../../app/lib/dto/IdentityDTO"; import { PeerDTO } from "../../../app/lib/dto/PeerDTO"; import { BmaApi } from "../../../app/modules/bma/lib/network"; import { DBIdentity } from "../../../app/lib/dal/sqliteDAL/IdentityDAL"; import { CertificationDTO } from "../../../app/lib/dto/CertificationDTO"; import { BlockchainService } from "../../../app/service/BlockchainService"; import { PeeringService } from "../../../app/service/PeeringService"; import { ConfDTO } from "../../../app/lib/dto/ConfDTO"; import { FileDAL } from "../../../app/lib/dal/fileDAL"; import { MembershipDTO } from "../../../app/lib/dto/MembershipDTO"; import { TransactionDTO } from "../../../app/lib/dto/TransactionDTO"; import { Key } from "../../../app/lib/common-libs/crypto/keyring"; import { WS2PConnection } from "../../../app/modules/ws2p/lib/WS2PConnection"; import { WS2PMessageHandler } from "../../../app/modules/ws2p/lib/impl/WS2PMessageHandler"; import { WS2PCluster } from "../../../app/modules/ws2p/lib/WS2PCluster"; import { WS2PServer } from "../../../app/modules/ws2p/lib/WS2PServer"; import { TestUser } from "./TestUser"; import { WS2PClient } from "../../../app/modules/ws2p/lib/WS2PClient"; import { DBBlock } from "../../../app/lib/db/DBBlock"; import { DBPeer } from "../../../app/lib/db/DBPeer"; import { WS2PRequester } from "../../../app/modules/ws2p/lib/WS2PRequester"; import { ForcedBlockValues } from "../../../app/modules/prover/lib/blockGenerator"; import { LevelMIndexExpiresOnIndexer } from "../../../app/lib/dal/indexDAL/leveldb/indexers/LevelMIndexExpiresOnIndexer"; export declare const getNewTestingPort: () => number; export declare const simpleUser: (uid: string, keyring: { pub: string; sec: string; }, server: TestingServer) => TestUser; export declare const simpleNetworkOf2NodesAnd2Users: (options: any) => Promise<{ s1: TestingServer; s2: TestingServer; cat: TestUser; tac: TestUser; }>; export declare const simpleNodeWith2Users: (options: any) => Promise<{ s1: TestingServer; cat: TestUser; tac: TestUser; }>; export declare const simpleNodeWith2otherUsers: (options: any) => Promise<{ s1: TestingServer; tic: TestUser; toc: TestUser; }>; export declare const createUser: (uid: string, pub: string, sec: string, defaultServer: Server) => Promise; export declare const fakeSyncServer: (currency: string, readBlocksMethod: any, readParticularBlockMethod: any, onPeersRequested: any) => Promise<{ host: string; port: number; }>; /** * Creates a new memory duniter server for Unit Test purposes. * @param conf */ export declare const server: (conf: any) => TestingServer; export declare const simpleTestingServer: (conf: any) => TestingServer; export declare const NewTestingServer: (conf: any) => TestingServer; export declare const serverWaitBlock: (server: Server, number: number) => Promise; export declare const waitToHaveBlock: (server: Server, number: number) => Promise; export declare const waitForkResolution: (server: Server, number: number) => Promise; export declare const waitForkWS2PConnection: (server: Server, pubkey: string) => Promise; export declare const waitForkWS2PDisconnection: (server: Server, pubkey: string) => Promise; export declare const waitForHeads: (server: Server, nbHeads: number) => Promise; export declare class TestingServer { private port; private server; private prover; permaProver: PermanentProver; bma: BmaApi; constructor(port: number, server: Server); get _server(): Server; get BlockchainService(): BlockchainService; get PeeringService(): PeeringService; get conf(): ConfDTO; get dal(): FileDAL; get logger(): any; get home(): string; initWithDAL(): Promise; revert(): Promise; resolve(filterFunc?: (b: DBBlock) => boolean): Promise; resolveForError(): Promise; getMindexExpiresOnIndexer(): LevelMIndexExpiresOnIndexer; resolveFork(): Promise; resetHome(): Promise; on(event: string, f: any): Server; recomputeSelfPeer(): Promise; writeBlock(obj: any): Promise; writeRawBlock(raw: string): Promise; writeIdentity(obj: any): Promise; writeCertification(obj: any): Promise; writeMembership(obj: any): Promise; writeRevocation(obj: any): Promise; writeTransaction(obj: any): Promise; writePeer(obj: any): Promise; pullingEvent(type: string, number: number): Promise; exportAllDataAsZIP(): Promise; unplugFileSystem(): Promise; importAllDataFromZIP(zipFile: string): Promise; push(chunk: any, encoding?: string): boolean; pipe(writable: stream.Writable): stream.Writable; initDalBmaConnections(): Promise; url(uri: string): string; get(uri: string): any; post(uri: string, obj: any): any; expect(uri: string, expectations: any): Promise; expectThat(uri: string, expectations: any): Promise; expectJSON(uri: string, expectations: any): Promise; expectError(uri: string, code: number, message?: string): Promise; syncFrom(otherServer: Server, fromIncuded: number, toIncluded: number): any; until(type: string, count: number): Promise; justCommit(options?: any): Promise; commit(options?: ForcedBlockValues | null): Promise; resolveExistingBlock(filterFunc: (b: DBBlock) => boolean): Promise; generateNext(options: any): any; commitWaitError(options: any, expectedError: string): Promise; commitExpectError(options: any): Promise; lookup2identity(search: string): Promise; readBlock(number: number): Promise; makeNext(overrideProps: any): Promise; sharePeeringWith(otherServer: TestingServer): Promise; getPeer(): Promise; waitToHaveBlock(number: number): Promise; waitForHeads(nbHeads: number): Promise; waitForkResolution(number: number): Promise; postIdentity(idty: any): any; postCert(cert: any): any; postMembership(ms: any): any; postRevocation(rev: RevocationDTO): any; postBlock(block: BlockDTO): any; postRawTX(rawTX: any): any; postPeer(peer: any): any; prepareForNetwork(): Promise; disableBMA(): Promise; startBlockComputation(): void; stopBlockComputation(): Promise; closeCluster(): Promise; enableWS2P(port?: number): Promise; } export interface TestWS2PAPI { connect: (pair: Key, ws2pId: string) => WS2PRequester; connectForSync: (pair: Key, ws2pId: string) => WS2PRequester; host: string; port: number; } export declare function newWS2PBidirectionnalConnection(currency: string, k1: Key, k2: Key, serverHandler: WS2PMessageHandler): Promise<{ p1: WS2PConnection; p2: WS2PConnection; wss: any; }>; export declare const simpleWS2PNetwork: (s1: TestingServer, s2: TestingServer) => Promise<{ w1: WS2PConnection; ws2pc: WS2PClient; wss: WS2PServer; cluster1: WS2PCluster; cluster2: WS2PCluster; }>; export declare function simpleTestingConf(now: number | undefined, pair: { pub: string; sec: string; }): any; export declare function catUser(server: TestingServer): TestUser; export declare function tacUser(server: TestingServer): TestUser; export declare function tocUser(server: TestingServer): TestUser; export declare function ticUser(server: TestingServer): TestUser;