Skip to content

Commit 5a0e79d

Browse files
run script at startup in pytest
1 parent 1b735db commit 5a0e79d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

programs/pyeos/pytest/pytest.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <eosiolib_native/vm_api.h>
44
#include <eosio/chain/eos_api.hpp>
55

6+
#include <fc/io/fstream.hpp>
7+
68
#include "debug_context.hpp"
79

810
using namespace eosio;
@@ -149,6 +151,7 @@ static int vm_run_script_(const char* str) {
149151
}
150152

151153
int main(int argc, char** argv) {
154+
152155
init_wallet();
153156

154157
get_vm_api()->is_unittest_mode = is_unittest_mode;
@@ -167,13 +170,13 @@ int main(int argc, char** argv) {
167170

168171
vm_run_script = get_vm_api()->vm_run_script;
169172
get_vm_api()->vm_run_script = vm_run_script_; //("print('hello,world')");
170-
try {
171-
get_vm_api()->vm_run_script("print('hello,world')");
172-
} catch (...) {
173-
vmdlog("+++%s\n", fc::exception::current_exception->to_detail_string().c_str());
174-
}
175173

176-
vmdlog("++++%p \n", fc::exception::current_exception);
174+
if (appbase::app().has_option("script")) {
175+
string content;
176+
string script = appbase::app().get_option("script");
177+
fc::read_file_contents(script, content);
178+
get_vm_api()->vm_run_script(content.c_str());
179+
}
177180

178181
try {
179182
main_tester->create_account(N(newacc));

0 commit comments

Comments
 (0)