mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Emulator improvements (#687)
* ticktock, unixtime, optional config * documentation * fix account.now * emulate tick/tock for emscripten * remove excessive check * limit stack serialization calls
This commit is contained in:
parent
86623b4cea
commit
c527bfeceb
6 changed files with 154 additions and 20 deletions
|
@ -12,6 +12,8 @@ struct TransactionEmulationParams {
|
|||
uint64_t lt;
|
||||
td::optional<std::string> rand_seed_hex;
|
||||
bool ignore_chksig;
|
||||
bool is_tick_tock;
|
||||
bool is_tock;
|
||||
bool debug_enabled;
|
||||
};
|
||||
|
||||
|
@ -41,6 +43,16 @@ td::Result<TransactionEmulationParams> decode_transaction_emulation_params(const
|
|||
TRY_RESULT(debug_enabled, td::get_json_object_bool_field(obj, "debug_enabled", false));
|
||||
params.debug_enabled = debug_enabled;
|
||||
|
||||
TRY_RESULT(is_tick_tock, td::get_json_object_bool_field(obj, "is_tick_tock", true, false));
|
||||
params.is_tick_tock = is_tick_tock;
|
||||
|
||||
TRY_RESULT(is_tock, td::get_json_object_bool_field(obj, "is_tock", true, false));
|
||||
params.is_tock = is_tock;
|
||||
|
||||
if (is_tock && !is_tick_tock) {
|
||||
return td::Status::Error("Inconsistent parameters is_tick_tock=false, is_tock=true");
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
@ -137,7 +149,12 @@ const char *emulate(const char *config, const char* libs, int verbosity, const c
|
|||
return strdup(R"({"fail":true,"message":"Can't set params"})");
|
||||
}
|
||||
|
||||
auto tx = transaction_emulator_emulate_transaction(em, account, message);
|
||||
const char *result;
|
||||
if (decoded_params.is_tick_tock) {
|
||||
result = transaction_emulator_emulate_tick_tock_transaction(em, account, decoded_params.is_tock);
|
||||
} else {
|
||||
result = transaction_emulator_emulate_transaction(em, account, message);
|
||||
}
|
||||
|
||||
transaction_emulator_destroy(em);
|
||||
|
||||
|
@ -145,12 +162,12 @@ const char *emulate(const char *config, const char* libs, int verbosity, const c
|
|||
{
|
||||
td::JsonBuilder jb;
|
||||
auto json_obj = jb.enter_object();
|
||||
json_obj("output", td::JsonRaw(td::Slice(tx)));
|
||||
json_obj("output", td::JsonRaw(td::Slice(result)));
|
||||
json_obj("logs", logger.get_string());
|
||||
json_obj.leave();
|
||||
output = strdup(jb.string_builder().as_cslice().c_str());
|
||||
}
|
||||
free((void*) tx);
|
||||
free((void*) result);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue