All files / src/tests/integrationTests start.js

100% Statements 26/26
50% Branches 1/2
66.67% Functions 2/3
100% Lines 26/26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 521x 1x 1x   1x 1x   1x   1x 1x 1x     1x   1x 1x 1x             1x   1x     1x   1x 1x 1x   1x 1x   1x   1x       1x 1x       1x  
const assert = require('assert')
const fs = require('fs-extra')
const interbit = require('../../')
 
const assertChainsConfigured = require('./assertChainsConfigured')
const log = require('../../log')
 
const testStart = async () => {
  let dbPath
  const dbCleanup = async () => {
    Eif (dbPath) {
      await fs.remove(dbPath)
    }
  }
  let interbitCleanup = () => {}
 
  try {
    dbPath = `./db-${Date.now()}`
    const options = {
      // eslint-disable-next-line
      config: require('./interbit.config'),
      noWatch: true,
      dbPath
    }
 
    log.info(options)
 
    const { cli, hypervisor, chainManifest, cleanup } = await interbit.start(
      options
    )
    interbitCleanup = cleanup
 
    assert.ok(cli)
    assert.ok(hypervisor)
    assert.ok(chainManifest)
 
    log.info('BOOTED THE INTERBITS WEOOOO!!!')
    log.info(chainManifest)
 
    await assertChainsConfigured(cli, chainManifest)
 
    log.success(
      'interbit.start(options): First joined to second and shared state'
    )
  } finally {
    await interbitCleanup()
    await dbCleanup()
  }
}
 
module.exports = testStart