import Core from '../Core' ; import { MongoClient } from 'mongodb' ; import { ConsoleLogger } from '@sidetree/common' ; import { MockCas } from '@sidetree/cas' ; import { MockLedger } from '@sidetree/ledger' ; import sidetreeTestNodeCoreConfig from '../configs/sidetree-test-node-config.json' ; import sidetreeTestNodeCoreVersions from '../configs/sidetree-test-node-core-versions.json' ; export { sidetreeTestNodeCoreConfig , sidetreeTestNodeCoreVersions } ; export const waitSeconds = async ( seconds ) => { return new Promise ( ( resolve ) => { setTimeout ( resolve , seconds * 1000 ) ; } ) ; } ; export const getTestSidetreeNodeInstance = async ( ) => { const cas = new MockCas ( ) ; await cas . initialize ( ) ; const ledger = new MockLedger ( ) ; const sidetreeNodeInstance = new Core ( sidetreeTestNodeCoreConfig as any , sidetreeTestNodeCoreVersions as any , cas , ledger ) ; await sidetreeNodeInstance . initialize ( new ConsoleLogger ( ) ) ; return sidetreeNodeInstance ; } ; export const clearCollection = async ( collectionName ) => { const client = await MongoClient . connect ( sidetreeTestNodeCoreConfig . mongoDbConnectionString , { useUnifiedTopology : true , useNewUrlParser : true } as any ) ; const db = await client . db ( sidetreeTestNodeCoreConfig . databaseName ) ; const collection = db . collection ( collectionName ) ; await collection . deleteMany ( { } ) ; await client . close ( ) ; } ;