Skip to content

Commit

Permalink
feat(config): fix config parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
halibobo1205 committed Dec 12, 2024
1 parent 7026e9b commit dc332ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
16 changes: 7 additions & 9 deletions framework/src/main/java/org/tron/core/config/args/Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,21 +367,19 @@ private static Map<String, String[]> getOptionGroup() {
* set parameters.
*/
public static void setParam(final String[] args, final String confFileName) {
Config config = Configuration.getByFileName(PARAMETER.shellConfFileName, confFileName);
setParam(args, config);
}

/**
* set parameters.
*/
public static void setParam(final String[] args, final Config config) {

JCommander.newBuilder().addObject(PARAMETER).build().parse(args);
if (PARAMETER.version) {
printVersion();
ExitManager.getInstance().exit(ExitReason.NORMAL_SHUTDOWN);
}
Config config = Configuration.getByFileName(PARAMETER.shellConfFileName, confFileName);
setParam(config);
}

/**
* set parameters.
*/
public static void setParam(final Config config) {
if (config.hasPath(Constant.NET_TYPE)
&& Constant.TESTNET.equalsIgnoreCase(config.getString(Constant.NET_TYPE))) {
Wallet.setAddressPreFixByte(Constant.ADD_PRE_FIX_BYTE_TESTNET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void testInitService() {
storage.put("storage.db.directory", "database");
Config config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage));
// test default value
Args.setParam(new String[] {}, config);
Args.setParam(config);
Assert.assertTrue(Args.getInstance().isRpcEnable());
Assert.assertTrue(Args.getInstance().isRpcSolidityEnable());
Assert.assertTrue(Args.getInstance().isRpcPBFTEnable());
Expand All @@ -185,7 +185,7 @@ public void testInitService() {
storage.put("node.jsonrpc.httpPBFTEnable", "true");
config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage));
// test value
Args.setParam(new String[] {}, config);
Args.setParam(config);
Assert.assertTrue(Args.getInstance().isRpcEnable());
Assert.assertTrue(Args.getInstance().isRpcSolidityEnable());
Assert.assertTrue(Args.getInstance().isRpcPBFTEnable());
Expand All @@ -208,7 +208,7 @@ public void testInitService() {
storage.put("node.jsonrpc.httpPBFTEnable", "false");
config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage));
// test value
Args.setParam(new String[] {}, config);
Args.setParam(config);
Assert.assertFalse(Args.getInstance().isRpcEnable());
Assert.assertFalse(Args.getInstance().isRpcSolidityEnable());
Assert.assertFalse(Args.getInstance().isRpcPBFTEnable());
Expand All @@ -231,7 +231,7 @@ public void testInitService() {
storage.put("node.jsonrpc.httpPBFTEnable", "true");
config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage));
// test value
Args.setParam(new String[] {}, config);
Args.setParam(config);
Assert.assertFalse(Args.getInstance().isRpcEnable());
Assert.assertFalse(Args.getInstance().isRpcSolidityEnable());
Assert.assertTrue(Args.getInstance().isRpcPBFTEnable());
Expand Down

0 comments on commit dc332ee

Please sign in to comment.