diff --git a/package.json b/package.json index 5e7e091..490942d 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "scripts": { "build": "babel src --out-dir dist", "build:ci": "yarn build && cp -f src/index.d.ts dist", - "test:unit": "jest -c jest.config.unit.js", + "test:unit": "jest -c jest.config.unit.js --detectOpenHandles", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs" }, diff --git a/src/emuContainer/index.js b/src/emuContainer/index.js index e2bb599..c7275ee 100644 --- a/src/emuContainer/index.js +++ b/src/emuContainer/index.js @@ -19,11 +19,11 @@ export const BOLOS_SDK = "/project/deps/nanos-secure-sdk"; export const DEFAULT_APP_PATH = "/project/app/bin"; export const DEFAULT_APP_NAME = "app.elf"; export const DEFAULT_VNC_PORT = "8001"; +const Resolve = require("path").resolve; export default class EmuContainer { constructor(elfPath, image) { // eslint-disable-next-line global-require - const Resolve = require("path").resolve; this.image = image; this.elfPath = Resolve(elfPath); } @@ -84,15 +84,9 @@ export default class EmuContainer { }); } */ - stop() { + async stop() { const { currentContainer } = this; - return new Promise((resolve, reject) => { - return currentContainer.stop({ t: 0 }).then(function() { - return currentContainer.remove().then(function() { - console.log("Container stopped!"); - resolve(true); - }); - }); - }); + await currentContainer.stop({ t: 0 }); + await currentContainer.remove(); } } diff --git a/src/index.js b/src/index.js index 2b04c52..dd4f136 100644 --- a/src/index.js +++ b/src/index.js @@ -103,7 +103,10 @@ export default class Zemu { } async connect() { - this.transport = await TransportHttp(this.transport_url).create(1000); + // FIXME: Can we detect open ports? + Zemu.delay(1000); + + this.transport = await TransportHttp(this.transport_url).open(this.transport_url); await this.connectVNC(); } diff --git a/tests/basic.spec.js b/tests/basic.spec.js index c046205..b8c719b 100644 --- a/tests/basic.spec.js +++ b/tests/basic.spec.js @@ -16,7 +16,7 @@ import { expect, test } from "jest"; import Zemu from "../src"; -jest.setTimeout(20000); +jest.setTimeout(10000); const DEMO_APP_PATH = "bin/demoApp"; test("Zemu-Start&Close", async () => { @@ -27,7 +27,6 @@ test("Zemu-Start&Close", async () => { } finally { await sim.close(); } - expect(true).toEqual(true); }); test("Zemu-Snapshot", async () => {