Skip to content

Commit

Permalink
feat: update service runner from multi-geth to core-geth
Browse files Browse the repository at this point in the history
  • Loading branch information
zcstarr committed Mar 23, 2020
1 parent 0a56e8e commit c5327ab
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -64,7 +64,7 @@ Service Runner improves the dApp development cycle, by reducing the number of st

### Supported Services

Currently it supports `multi-geth` with the following environments:
Currently it supports `core-geth` with the following environments:

- `mainnet (ETC)`
- `kotti`
Expand Down Expand Up @@ -99,7 +99,7 @@ Then require it into any module.
const { ServiceRunner } = require('@etclabscore/jade-service-runner-client');
const ERPC = require('@etclabscore/ethereum-json-rpc');
const serviceRunner = new ServiceRunner({ transport: { type: "http", port: 8002, host: "localhost" } });
const serviceName = 'multi-geth';
const serviceName = 'core-geth';
const successful = await serviceRunner.installService(serviceName);
if (successful === false) throw new Error('Service not installed')
const serviceConfig = serviceRunner.start(serviceName, 'kotti');
Expand Down
4 changes: 2 additions & 2 deletions client.ts
@@ -1,10 +1,10 @@
/*const ServiceRunner = require('./build/client/typescript/build/index').default;
const client = new ServiceRunner({ transport: { type: "http", port: 8002, host: "localhost" } });
client.installService("multi-geth", "1.9.0")
client.installService("core-geth", "1.9.0")
.then(() => client.listInstalledServices())
.then(() => client.listRunningServices())
.then(console.log)
.then(() => client.startService("multi-geth", "1.9.0", "mainnet"))
.then(() => client.startService("core-geth", "1.9.0", "mainnet"))
.then(console.log)
.then(() => client.listRunningServices())
.then(console.log)
Expand Down
8 changes: 4 additions & 4 deletions examples/index.ts
Expand Up @@ -13,20 +13,20 @@ const ethClient = new EthClient({
host: "localhost",
port: 8002,
type: "http",
path: "multi-geth/mainnet/1.9.0",
path: "core-geth/mainnet/1.9.0",
},
});
console.log("starting client");
client.installService("multi-geth", "1.9.0")
client.installService("core-geth", "1.9.0")
.then(() => client.listInstalledServices())
.then(() => client.listRunningServices())
.then(console.log) //tslint:disable-line
.then(() => client.startService("multi-geth", "1.9.0", "mainnet"))
.then(() => client.startService("core-geth", "1.9.0", "mainnet"))
.then(console.log)//tslint:disable-line
.then(() => client.listRunningServices())
.then(console.log)//tslint:disable-line
client.startService("multi-geth", "1.9.0", "mainnet")
client.startService("core-geth", "1.9.0", "mainnet")
.then(() => ethClient.eth_getBalance("0xc1912fee45d61c87cc5ea59dae31190fffff232d", "0x0"))
.then(console.log)
.catch((e) => {
Expand Down
2 changes: 1 addition & 1 deletion fixtures/src/util.ts
Expand Up @@ -111,7 +111,7 @@ export const mockConfig: any = {
{
name: "dev",
args: {
start: ["--datadir", "multi-geth"],
start: ["--datadir", "core-geth"],
stop: [],
teardown: [],
},
Expand Down
24 changes: 12 additions & 12 deletions src/lib/config.test.ts
Expand Up @@ -8,26 +8,26 @@ describe("configuration test", () => {
const mockConfig = {
services: [
{
version: "1.9.7",
name: "multi-geth",
version: "1.11.2",
name: "core-geth",
environments: [
{
name: "test-dev",
args: {
start: ["--datadir ${svc_runner_data_path}/multi-geth"],
start: ["--datadir ${svc_runner_data_path}/core-geth"],
stop: [],
teardown: [],
},
}],
},
{
name: "eth-classic",
version: "1.9.7",
version: "1.11.2",
environments: [
{
name: "dev",
args: {
start: ["--datadir ${svc_runner_data_path}/multi-geth"],
start: ["--datadir ${svc_runner_data_path}/core-geth"],
stop: [],
teardown: [],
},
Expand Down Expand Up @@ -56,12 +56,12 @@ describe("configuration test", () => {
new Config(mockConfig); // tslint:disable-line
});

it("should retrieve service info", () => {
it.only("should retrieve service info", () => {
const cfg = new Config(mockConfig);
const svc = cfg.getService("multi-geth", "1.9.7", "osx");
expect(svc.name === "multi-geth").toBe(true);
const svc = cfg.getService("core-geth", "1.11.2", "osx");
expect(svc.name === "core-geth").toBe(true);
expect(svc.environments.find((env: any) => env.name === "test-dev"));
const defaultService = defaultConfig.services.find((service: any) => service.name === "multi-geth") as any;
const defaultService = defaultConfig.services.find((service: any) => service.name === "core-geth") as any;
expect(_.isEqual(svc.commands, defaultService.os.osx.commands)).toBe(true);
});

Expand All @@ -86,12 +86,12 @@ describe("configuration test", () => {

it("should retrieve installation information", () => {
const config = new Config(mockConfig);
const service = config.getService("multi-geth", "1.9.7", OSTypes.OSX);
expect(service.name === "multi-geth").toBe(true);
const service = config.getService("core-geth", "1.11.2", OSTypes.OSX);
expect(service.name === "core-geth").toBe(true);
expect(service.rpcPort).toEqual("${DYNAMIC_TCP_PORT_1}");
});

it("should properly default configure multi-geth", () => {
it("should properly default configure core-geth", () => {
const config = new Config({});
const env = config.config.services[0].environments.find((e) => e.name === "mainnet");
expect(env).toBeDefined();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/config.ts
Expand Up @@ -111,7 +111,7 @@ export class Config {
* @returns The config of a service scoped by OS and service name
*/
public getService(serviceName: string, ver: string, os: string): Service {
const services = this.config.services.find((s: Services) => s.name === serviceName && s.version === ver) as Services;
const services = this.config.services.find((s: Services) => s.name === serviceName) as Services;
if (services === undefined || services.os.hasOwnProperty(os) === false) {
const errMsg = `Could not find service ${serviceName} with ${os}`;
logger.error(errMsg);
Expand Down Expand Up @@ -164,7 +164,7 @@ export class Config {
const mergedConfig = _.cloneDeep(config);
try {
other.services.forEach((svc: any) => {
const serviceIdx = config.services.findIndex((s: Services) => s.name === svc.name);
const serviceIdx = config.services.findIndex((s: Services) => s.name === svc.name && s.version === svc.version);
if (serviceIdx > -1) {
const service = mergedConfig.services[serviceIdx];
svc.environments.every((env: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/connectionManager.test.ts
Expand Up @@ -27,7 +27,7 @@ describe("ConnectionManager tests", () => {
backendClient = new WebSocket(location);
serviceNotifications = new EventEmitter();
connections = new Set<ConnectionInfo>([{ host: "localhost", port: tcpPort, protocol: "ws" }]);
serviceEvent = { env: "dev", name: "multi-geth", protocol: "ws", rpcPort: `${address.port}`, version: "1.0.0" };
serviceEvent = { env: "dev", name: "core-geth", protocol: "ws", rpcPort: `${address.port}`, version: "1.0.0" };
});

it("should handle connection life cycle", (done) => {
Expand All @@ -37,7 +37,7 @@ describe("ConnectionManager tests", () => {
serviceNotifications.emit("launched", serviceEvent);
const connMan = new ConnectionManager(connections, router);
connMan.setupConnections();
const location = `ws://localhost:${tcpPort}/multi-geth/dev/1.0.0`;
const location = `ws://localhost:${tcpPort}/core-geth/dev/1.0.0`;
const client = new WebSocket(location);
client.on("open", async () => {
client.send(TEST_MESSAGE);
Expand Down
38 changes: 19 additions & 19 deletions src/service-runner-config.json
Expand Up @@ -2,9 +2,9 @@
"$schema": "./lib/service-runner-schema.json",
"services": [
{
"name": "multi-geth",
"name": "core-geth",
"rpcPort": "${DYNAMIC_TCP_PORT_1}",
"version": "1.9.9",
"version": "1.11.2",
"summary": "An Ethereum Classic and Ethereum client",
"environments": [
{
Expand All @@ -14,9 +14,9 @@
"start": [
"--classic",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/classic",
"${SERVICE_DIR}/core-geth/1.11.2/classic",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/classic/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/classic/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand All @@ -42,9 +42,9 @@
"start": [
"--mordor",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/mordor",
"${SERVICE_DIR}/core-geth/1.11.2/mordor",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/mordor/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/mordor/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand All @@ -70,9 +70,9 @@
"start": [
"--kotti",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/kotti",
"${SERVICE_DIR}/core-geth/1.11.2/kotti",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/kotti/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/kotti/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand Down Expand Up @@ -100,9 +100,9 @@
"start": [
"--dev",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/dev",
"${SERVICE_DIR}/core-geth/1.11.2/dev",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/dev/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/dev/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand All @@ -127,9 +127,9 @@
"args": {
"start": [
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/ethereum",
"${SERVICE_DIR}/core-geth/1.11.2/ethereum",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/ethereum/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/ethereum/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand All @@ -155,9 +155,9 @@
"start": [
"--goerli",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/goerli",
"${SERVICE_DIR}/core-geth/1.11.2/goerli",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/goerli/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/goerli/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand All @@ -183,9 +183,9 @@
"start": [
"--rinkeby",
"--datadir",
"${SERVICE_DIR}/multi-geth/1.9.9/rinkeby",
"${SERVICE_DIR}/core-geth/1.11.2/rinkeby",
"--ipcpath",
"${SERVICE_DIR}/multi-geth/1.9.9/rinkeby/geth.ipc",
"${SERVICE_DIR}/core-geth/1.11.2/rinkeby/geth.ipc",
"--port",
"${DYNAMIC_TCP_PORT_2}",
"--rpc",
Expand Down Expand Up @@ -222,7 +222,7 @@
"teardown": ""
},
"assets": [
"https://github.com/etclabscore/multi-geth/releases/download/v1.9.9-etclabscore/multi-geth-osx.zip"
"https://github.com/etclabscore/core-geth/releases/download/v1.11.2/core-geth-osx-v1.11.2.zip"
]
},
"linux": {
Expand All @@ -241,7 +241,7 @@
"teardown": ""
},
"assets": [
"https://github.com/etclabscore/multi-geth/releases/download/v1.9.9-etclabscore/multi-geth-linux.zip"
"https://github.com/etclabscore/core-geth/releases/download/v1.11.2/core-geth-linux-v1.11.2.zip"
]
},
"windows": {
Expand All @@ -252,7 +252,7 @@
"teardown": ""
},
"assets": [
"https://github.com/etclabscore/multi-geth/releases/download/v1.9.9-etclabscore/multi-geth-win64.zip"
"https://github.com/etclabscore/core-geth/releases/download/v1.11.2/core-geth-win64-v1.11.2.zip"
]
}
}
Expand Down

0 comments on commit c5327ab

Please sign in to comment.