From 6f2c307772c185cbeda906ccf3d9957c0a47833b Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Wed, 13 Sep 2023 09:03:35 +0200 Subject: [PATCH] Starting clean --- src/dev_tools/makeClass/handle_gocmds.cpp | 21 +++++++++++++++---- .../makeClass/handle_sdk_py_paths.cpp | 3 +-- .../makeClass/handle_sdk_ts_paths.cpp | 3 +-- src/dev_tools/testRunner/options.cpp | 1 + src/dev_tools/utillib/conversions.cpp | 7 +------ src/dev_tools/utillib/conversions.h | 1 - 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/dev_tools/makeClass/handle_gocmds.cpp b/src/dev_tools/makeClass/handle_gocmds.cpp index befa8f1d87..7e926ccfd7 100644 --- a/src/dev_tools/makeClass/handle_gocmds.cpp +++ b/src/dev_tools/makeClass/handle_gocmds.cpp @@ -384,6 +384,7 @@ string_q get_godefaults(const CCommandOption& cmd) { for (auto p : *((CCommandOptionArray*)cmd.members)) { if (!isDef(p)) { string_q val = substitute(p.def_val, "NOPOS", "utils.NOPOS"); + val = substitute(val, "trueblocks.eth", "\"trueblocks.eth\""); os << "\t" << padRight(p.Format("[{VARIABLE}]") + ": ", wid + 2, ' ') << val << "," << endl; } } @@ -408,9 +409,17 @@ string_q get_testlogs(const CCommandOption& cmd) { } else if (startsWith(p.data_type, "list<") || p.data_type == "" || p.data_type == "
" || contains(p.data_type, "enum")) { - const char* STR_TESTLOG_STRING = - "\tlogger.TestLog(len(opts.[{VARIABLE}]) > 0, \"[{VARIABLE}]: \", opts.[{VARIABLE}])"; - os << p.Format(STR_TESTLOG_STRING) << endl; + if (!p.def_val.empty() && p.def_val != "\"\"" && p.def_val != "utils.NOPOS") { + const char* STR_TESTLOG_STRING = + "\tlogger.TestLog(len(opts.[{VARIABLE}]) > 0 && opts.[{VARIABLE}] != \"[{DEF_VAL}]\", " + "\"[{VARIABLE}]: \", opts.[{VARIABLE}])"; + p.def_val = substitute(p.def_val, "\"", ""); + os << p.Format(STR_TESTLOG_STRING) << endl; + } else { + const char* STR_TESTLOG_STRING = + "\tlogger.TestLog(len(opts.[{VARIABLE}]) > 0, \"[{VARIABLE}]: \", opts.[{VARIABLE}])"; + os << p.Format(STR_TESTLOG_STRING) << endl; + } } else if (p.data_type == "" || p.data_type == "") { const char* STR_TESTLOG_UINT = @@ -640,7 +649,11 @@ string_q get_goDefault(const CCommandOption& p) { return p.def_val; return "0.0"; } else if (p.go_intype == "string") { - return p.def_val; + if (contains(p.def_val, ".eth")) { // an address + return "\"" + p.def_val + "\""; + } else { + return p.def_val; + } } else if (p.go_intype == "uint64") { if (contains(p.def_val, "NOPOS")) { return "0"; diff --git a/src/dev_tools/makeClass/handle_sdk_py_paths.cpp b/src/dev_tools/makeClass/handle_sdk_py_paths.cpp index 70ae8c3542..5f14977391 100644 --- a/src/dev_tools/makeClass/handle_sdk_py_paths.cpp +++ b/src/dev_tools/makeClass/handle_sdk_py_paths.cpp @@ -75,8 +75,7 @@ bool COptions::handle_sdk_py_paths(CStringArray& pathsOut) { ostringstream params; for (auto p : members) { string_q line = " \"[{LONGNAME}]\": {\"hotkey\": \"[{HOTKEY}]\", \"type\": \"[{TYPE}]\"},\n"; - string_q optionName = substitute(toCamelCase(p.longName), "deleteme", "delete"); - + string_q optionName = toCamelCase(p.longName); if (!p.is_visible_docs && !contains(optionName, "cache")) { continue; } diff --git a/src/dev_tools/makeClass/handle_sdk_ts_paths.cpp b/src/dev_tools/makeClass/handle_sdk_ts_paths.cpp index a0f53d72f9..40f5631fa8 100644 --- a/src/dev_tools/makeClass/handle_sdk_ts_paths.cpp +++ b/src/dev_tools/makeClass/handle_sdk_ts_paths.cpp @@ -118,8 +118,7 @@ bool COptions::handle_sdk_ts_paths(CStringArray& pathsOut) { if (!p.is_visible_docs) { continue; } - string_q optionName = substitute(toCamelCase(p.longName), "deleteme", "delete"); - + string_q optionName = toCamelCase(p.longName); params << " " << optionName; params << (p.is_required ? "" : "?") << ": "; params << toTsType(p.data_type, imports) << ","; diff --git a/src/dev_tools/testRunner/options.cpp b/src/dev_tools/testRunner/options.cpp index 0ae45749b3..8c6cabf1dc 100644 --- a/src/dev_tools/testRunner/options.cpp +++ b/src/dev_tools/testRunner/options.cpp @@ -167,6 +167,7 @@ bool COptions::parseArguments(string_q& command) { SHOW_FIELD(CTestCase, "test_id"); + // TODO: this value is not in the testRunner config file, add it apiProvider = getGlobalConfig("testRunner")->getConfigStr("settings", "api_provider", "http://localhost:8080"); if (!endsWith(apiProvider, '/')) apiProvider += "/"; diff --git a/src/dev_tools/utillib/conversions.cpp b/src/dev_tools/utillib/conversions.cpp index 6aca1f8ccb..e800e03abc 100644 --- a/src/dev_tools/utillib/conversions.cpp +++ b/src/dev_tools/utillib/conversions.cpp @@ -240,7 +240,7 @@ address_t topic_2_Addr(const topic_t& topic) { //-------------------------------------------------------------------------------- address_t str_2_Addr(const string_q& str) { - if (isZeroAddr(str)) + if (isZeroHash(str)) return "0x0"; string_q ret = substitute(str, "0x", ""); @@ -357,11 +357,6 @@ bool isEtherAddr(const address_t& addr) { return toLower(addr) == FAKE_ETH_ADDRESS; } -//-------------------------------------------------------------------------------- -bool isZeroAddr(const address_t& addr) { - return isZeroHash(addr); -} - //-------------------------------------------------------------------------------- bool isNumeral(const string_q& test) { for (size_t i = 0; i < test.length(); i++) diff --git a/src/dev_tools/utillib/conversions.h b/src/dev_tools/utillib/conversions.h index 03429822d9..ebc3fe9d33 100644 --- a/src/dev_tools/utillib/conversions.h +++ b/src/dev_tools/utillib/conversions.h @@ -122,7 +122,6 @@ extern timestamp_t date_2_Ts(const string_q& str); //-------------------------------------------------------------------- extern bool isZeroHash(const hash_t& hash); -extern bool isZeroAddr(const address_t& addr); extern bool isEtherAddr(const address_t& addr); extern bool isNumeral(const string_q& test); extern bool isDouble(const string_q& test);