-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from ston-fi/upstream-2024.4.0
Upstream 2024.4.0
- Loading branch information
Showing
6 changed files
with
257 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,7 @@ | ||
mod tonlibjson; | ||
mod tvm_emulator; | ||
mod tx_emulator; | ||
|
||
pub use tonlibjson::*; | ||
pub use tvm_emulator::*; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_creates_client() { | ||
unsafe { | ||
let client = tonlib_client_json_create(); | ||
tonlib_client_set_verbosity_level(4); | ||
assert!(!client.is_null()); | ||
tonlib_client_json_send(client, "123\0".as_bytes().as_ptr() as *const i8); | ||
tonlib_client_json_receive(client, 1.0); | ||
tonlib_client_json_destroy(client); | ||
} | ||
} | ||
|
||
#[test] | ||
fn it_creates_emulator() { | ||
let code = "te6cckECCwEAAe0AART/APSkE/S88sgLAQIBYgIDAgLMBAUCA3pgCQoD79mRDjgEit8GhpgYC42Eit8H0gGADpj+mf9qJofQB9IGpqGEAKqThdRxgamqiq44L5cCSA/SB9AGoYEGhAMGuQ/QAYEogaKCF4BFAqkGQoAn0BLGeLZmZk9qpwQQg97svvKThdcYEakuAB8YEYAmACcYEvgsIH+XhAYHCACT38FCIBuCoQCaoKAeQoAn0BLGeLAOeLZmSRZGWAiXoAegBlgGSQfIA4OmRlgWUD5f/k6DvADGRlgqxniyg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EQCayz9QB/oCIs8WUAbPFiX6AlADzxbJUAXMI5FykXHiUAioE6CCCJiWgKoAggiYloCgoBS88uLFBMmAQPsAECPIUAT6AljPFgHPFszJ7VQAcFJ5oBihghBzYtCcyMsfUjDLP1j6AlAHzxZQB88WyXGAGMjLBSTPFlAG+gIVy2oUzMlx+wAQJBAjAA4QSRA4N18EAHbCALCOIYIQ1TJ223CAEMjLBVAIzxZQBPoCFstqEssfEss/yXL7AJM1bCHiA8hQBPoCWM8WAc8WzMntVADbO1E0PoA+kD6QNQwB9M/+gD6QDBRUaFSSccF8uLBJ8L/8uLCggiYloCqABagFrzy4sOCEHvdl97Iyx8Vyz9QA/oCIs8WAc8WyXGAGMjLBSTPFnD6AstqzMmAQPsAQBPIUAT6AljPFgHPFszJ7VSAAgyAINch7UTQ+gD6QPpA1DAE0x+CEBeNRRlSILqCEHvdl94TuhKx8uLF0z8x+gAwE6BQI8hQBPoCWM8WAc8WzMntVIH++ZZY=\0"; | ||
|
||
let code_slice = code.as_bytes(); | ||
let data_slice = data.as_bytes(); | ||
let code_packed = code_slice.as_ptr(); | ||
let data_packed = data_slice.as_ptr(); | ||
|
||
unsafe { | ||
let emulator = | ||
tvm_emulator_create(code_packed as *const i8, data_packed as *const i8, 2); | ||
tvm_emulator_run_get_method(emulator, 11111123, data_packed as *const i8); | ||
assert!(!emulator.is_null()); | ||
tvm_emulator_destroy(emulator); | ||
} | ||
} | ||
} | ||
pub use tx_emulator::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
extern "C" { | ||
pub fn tonlib_client_json_create() -> *mut ::std::os::raw::c_void; | ||
} | ||
extern "C" { | ||
|
||
pub fn tonlib_client_json_send( | ||
client: *mut ::std::os::raw::c_void, | ||
request: *const ::std::os::raw::c_char, | ||
); | ||
} | ||
extern "C" { | ||
|
||
pub fn tonlib_client_json_receive( | ||
client: *mut ::std::os::raw::c_void, | ||
timeout: f64, | ||
) -> *const ::std::os::raw::c_char; | ||
} | ||
extern "C" { | ||
|
||
pub fn tonlib_client_json_execute( | ||
client: *mut ::std::os::raw::c_void, | ||
request: *const ::std::os::raw::c_char, | ||
) -> *const ::std::os::raw::c_char; | ||
} | ||
extern "C" { | ||
|
||
pub fn tonlib_client_json_destroy(client: *mut ::std::os::raw::c_void); | ||
} | ||
extern "C" { | ||
|
||
pub fn tonlib_client_set_verbosity_level(verbosity_level: u32); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_creates_client() { | ||
unsafe { | ||
let client = tonlib_client_json_create(); | ||
tonlib_client_set_verbosity_level(4); | ||
assert!(!client.is_null()); | ||
tonlib_client_json_send(client, "123\0".as_bytes().as_ptr() as *const i8); | ||
tonlib_client_json_receive(client, 1.0); | ||
tonlib_client_json_destroy(client); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.