Skip to content

Commit

Permalink
reduce start up time
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Apr 7, 2020
1 parent 6fd4466 commit c602d5c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
14 changes: 4 additions & 10 deletions src/emuContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
}
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 1 addition & 2 deletions tests/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -27,7 +27,6 @@ test("Zemu-Start&Close", async () => {
} finally {
await sim.close();
}
expect(true).toEqual(true);
});

test("Zemu-Snapshot", async () => {
Expand Down

0 comments on commit c602d5c

Please sign in to comment.