-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test runner python module #318
Conversation
a18fee3
to
a7f7977
Compare
810fa1b
to
1444d0d
Compare
@anvacaru and @gtrepta can we add some tests of this functionality as well? Just a single Solidity file -> generated report files, and diff the files should be enough. Or we can just make sure the tool runs smoothly, and not record the output, as an initial test. But it probably would be better to start with too strong of testing (with the output files) and weaken it as it gets annoying. |
Co-authored-by: Everett Hildenbrandt <everett.hildenbrandt@gmail.com>
Co-authored-by: Everett Hildenbrandt <everett.hildenbrandt@gmail.com>
88b5dff
to
d49097f
Compare
kiele
Outdated
run_pyiele() { | ||
python3 -m pyiele "$@" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run_pyiele() { | |
python3 -m pyiele "$@" | |
} | |
run_pyiele() { | |
python3 -m pyiele --host "${host}" --port "${port}" --output "${output_path}" "$@" | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have to be
python3 -m pyiele "$@" --host "${host}" --port "${port}" --output "${output_path}"
Because the command {blackbox,test,compile,coverage}
is a positional parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second look, this might not work at all. None of these parameters are included in all of the commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to set the run_pyiele()
function to Everett's suggestion by moving the port
,host
, and output
parameters to the main parser (initially, they were subparser parameters).
kiele
Outdated
run_testrunner() { | ||
local run_file | ||
if [[ $# -gt 0 ]] && [ "$1" == "--help" ]; then | ||
run_pyiele test --help | ||
exit | ||
fi | ||
if ! nc -z "$kiele_host" "$kiele_port"; then | ||
fatal "No listener found on port $kiele_port" | ||
fi | ||
if [[ $# -gt 0 ]]; then | ||
if [[ -f "$1" ]] || [[ -d "$1" ]]; then | ||
run_file="$1"; shift | ||
if [[ "$run_file" == *.py ]]; then | ||
python3 "$run_file" | ||
else | ||
run_pyiele test --file "$run_file" --port "$kiele_port" "$@" | ||
fi | ||
else | ||
run_pyiele test --port "$kiele_port" "$@" | ||
fi | ||
else | ||
run_pyiele test --port "$kiele_port" "$@" | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run_testrunner() { | |
local run_file | |
if [[ $# -gt 0 ]] && [ "$1" == "--help" ]; then | |
run_pyiele test --help | |
exit | |
fi | |
if ! nc -z "$kiele_host" "$kiele_port"; then | |
fatal "No listener found on port $kiele_port" | |
fi | |
if [[ $# -gt 0 ]]; then | |
if [[ -f "$1" ]] || [[ -d "$1" ]]; then | |
run_file="$1"; shift | |
if [[ "$run_file" == *.py ]]; then | |
python3 "$run_file" | |
else | |
run_pyiele test --file "$run_file" --port "$kiele_port" "$@" | |
fi | |
else | |
run_pyiele test --port "$kiele_port" "$@" | |
fi | |
else | |
run_pyiele test --port "$kiele_port" "$@" | |
fi | |
} | |
run_testrunner() { | |
! nc -z "$kiele_host" "$kiele_port" || fatal "No listener found on port $kiele_port" | |
run_pyiele test "$@" | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion:
run_testrunner() { | |
local run_file | |
if [[ $# -gt 0 ]] && [ "$1" == "--help" ]; then | |
run_pyiele test --help | |
exit | |
fi | |
if ! nc -z "$kiele_host" "$kiele_port"; then | |
fatal "No listener found on port $kiele_port" | |
fi | |
if [[ $# -gt 0 ]]; then | |
if [[ -f "$1" ]] || [[ -d "$1" ]]; then | |
run_file="$1"; shift | |
if [[ "$run_file" == *.py ]]; then | |
python3 "$run_file" | |
else | |
run_pyiele test --file "$run_file" --port "$kiele_port" "$@" | |
fi | |
else | |
run_pyiele test --port "$kiele_port" "$@" | |
fi | |
else | |
run_pyiele test --port "$kiele_port" "$@" | |
fi | |
} | |
run_testrunner() { | |
local run_file cmd | |
if [[ $# -gt 0 ]] && [ "$1" == "--help" ]; then | |
run_pyiele test --help | |
exit | |
fi | |
if ! nc -z "$kiele_host" "$kiele_port"; then | |
fatal "No listener found on port $kiele_port" | |
fi | |
cmd=(run_pyiele test --port "$kiele_port" --host "$kiele_host") | |
if [[ $# -gt 0 ]] && ([[ -f "$1" ]] || [[ -d "$1" ]]); then | |
run_file="$1"; shift | |
if [[ "$run_file" == *.py ]]; then | |
cmd=( python3 "$run_file" ) | |
else | |
cmd+=( --file "$run_file" ) | |
fi | |
fi | |
"${cmd[@]}" "$@" | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --help
option should be handled once globally at the top, and if we want it to call the pyiele help there as well, then it should do that.
But we shouldn't duplicate all this stuff about calling help
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ehildenb. Initially, I added explicit help
calls because the check_listener
would prevent the help
message from being displayed if the midnight client wasn't active. For now I just removed all explicit calls.
kiele
Outdated
if ! nc -z "$kiele_host" "$kiele_port"; then | ||
fatal "No listener found on port $kiele_port" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factor out a check_listener
function in the Utilities section at the top, and use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: gtrepta <50716988+gtrepta@users.noreply.github.com>
Writing tests
pyiele
needs to be imported.port
,passphrase
,spending-key
,gas-limit
and other parameters are defined in the config.py file.deploy_contract(walletId, sender, bytecode)
.run_function(f_name, f_args, walletId, sender, to)
.send(rpc)
.Running tests
>$ python3 test_erc20.sol