Skip to content

Commit

Permalink
Enable txDepthRequiredForConfirmation.live (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkent600 authored Aug 10, 2018
1 parent 44d288c commit b8d6a76
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/configService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@ export class ConfigService {
public static data: any;

public static get(setting: string): any {
return ConfigService.data[setting];
const parts = setting.split(".");
let result;
if (parts.length) {
result = ConfigService.data;
parts.forEach((part: any): void => {
result = result[part];
});
}
return result;
}

public static set(setting: string, value: any): void {
ConfigService.data[setting] = value;
const parts = setting.split(".");
const count = parts.length - 1;
let section = ConfigService.data;
if (count > 0) {
for (let i = 0; i < count; ++i) {
section = section[parts[i]];
}
}
section[parts[count]] = value;
}

constructor() {
Expand Down
14 changes: 14 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import * as helpers from "./helpers";

describe("Misc", () => {

it("can set/get txDepthRequiredForConfirmation", async () => {

let setting = ConfigService.get("logLevel");
assert.equal(setting, 9);

setting = ConfigService.get("txDepthRequiredForConfirmation.live");
assert.equal(setting, 20);

setting = ConfigService.set("txDepthRequiredForConfirmation.live", 10);

setting = ConfigService.get("txDepthRequiredForConfirmation.live");
assert.equal(setting, 10);
});

it("can check correct wrapper", async () => {
const contractNameShouldBe = "GenesisProtocol";
const contractNameDontWant = "AbsoluteVote";
Expand Down

0 comments on commit b8d6a76

Please sign in to comment.