Skip to content

Commit

Permalink
Starting clean
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Sep 13, 2023
1 parent 7d7676c commit 6f2c307
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
21 changes: 17 additions & 4 deletions src/dev_tools/makeClass/handle_gocmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -408,9 +409,17 @@ string_q get_testlogs(const CCommandOption& cmd) {

} else if (startsWith(p.data_type, "list<") || p.data_type == "<string>" || p.data_type == "<address>" ||
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 == "<blknum>" || p.data_type == "<uint64>") {
const char* STR_TESTLOG_UINT =
Expand Down Expand Up @@ -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";
Expand Down
3 changes: 1 addition & 2 deletions src/dev_tools/makeClass/handle_sdk_py_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/dev_tools/makeClass/handle_sdk_ts_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) << ",";
Expand Down
1 change: 1 addition & 0 deletions src/dev_tools/testRunner/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "/";
Expand Down
7 changes: 1 addition & 6 deletions src/dev_tools/utillib/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", "");
Expand Down Expand Up @@ -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++)
Expand Down
1 change: 0 additions & 1 deletion src/dev_tools/utillib/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f2c307

Please sign in to comment.