From 82cba818f4a9e3d087ffe1898c81adfc3e9d547a Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 17:08:32 +0300 Subject: [PATCH 01/14] Default giver params --- ton_client/src/tests/mod.rs | 47 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/ton_client/src/tests/mod.rs b/ton_client/src/tests/mod.rs index 1146f82a1..5f4aea236 100644 --- a/ton_client/src/tests/mod.rs +++ b/ton_client/src/tests/mod.rs @@ -52,6 +52,10 @@ const DEFAULT_NETWORK_ADDRESS: &str = "http://localhost"; const ROOT_CONTRACTS_PATH: &str = "src/tests/contracts/"; const LOG_CGF_PATH: &str = "src/tests/log_cfg.yaml"; +const GIVER_ADDRESS_VAR: &str = "TON_GIVER_ADDRESS"; +const GIVER_SECRET_VAR: &str = "TON_GIVER_SECRET"; +const GIVER_KEYS_FILENAME: &str = "giverKeys.json"; + struct SimpleLogger; const MAX_LEVEL: log::LevelFilter = log::LevelFilter::Warn; @@ -244,21 +248,40 @@ impl TestClient { } pub fn giver_address() -> String { - const GIVER_ADDRESS_VAR: &str = "TON_GIVER_ADDRESS"; - std::env::var(GIVER_ADDRESS_VAR) - .expect(&format!("Please set giver's address in {} environment variable", GIVER_ADDRESS_VAR)) + if Self::node_se() { + "0:b5e9240fc2d2f1ff8cbb1d1dee7fb7cae155e5f6320e585fcc685698994a19a5".to_owned() + } else { + std::env::var(GIVER_ADDRESS_VAR) + .unwrap_or("0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13".to_owned()) + } } pub fn giver_keys() -> KeyPair { - const GIVER_KEYS_FILENAME: &str = "giverKeys.json"; - let keys_file = dirs::home_dir() - .expect("Error obtaining user's home dir") - .join(GIVER_KEYS_FILENAME); - let keys = std::fs::read_to_string(&keys_file) - .expect(&format!("Error reading file: {:?}", &keys_file)); - - serde_json::from_str(&keys) - .expect(&format!("Error parsing {:?} as JSON", &keys_file)) + if Self::node_se() { + KeyPair { + public: "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16".to_owned(), + secret: "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3".to_owned(), + } + } else { + if let Ok(secret) = std::env::var(GIVER_SECRET_VAR) { + let secret_key = ed25519_dalek::SecretKey::from_bytes(&hex::decode(&secret).unwrap()).unwrap(); + let public_key = ed25519_dalek::PublicKey::from(&secret_key); + KeyPair { + public: hex::encode(public_key.to_bytes()), + secret, + } + } else { + let keys_file = dirs::home_dir() + .expect("Error obtaining user's home dir") + .join(GIVER_KEYS_FILENAME); + let keys = std::fs::read_to_string(&keys_file) + .expect(&format!("Error reading file: {:?}", &keys_file)); + + serde_json::from_str(&keys) + .expect(&format!("Error parsing {:?} as JSON", &keys_file)) + } + } + } pub fn network_address() -> String { From 822cd1ecd8c332e6b7c38e7bdfc390eaa76f65f4 Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 18:20:43 +0300 Subject: [PATCH 02/14] Calculated giver address --- ton_client/src/net/tests.rs | 8 +- ton_client/src/processing/tests.rs | 2 +- ton_client/src/tests/common.rs | 2 +- ...{GiverWallet.abi.json => GiverV2.abi.json} | 78 +++++++++--------- .../src/tests/contracts/abi_v2/GiverV2.tvc | Bin 0 -> 999 bytes ton_client/src/tests/mod.rs | 64 +++++++------- 6 files changed, 76 insertions(+), 78 deletions(-) rename ton_client/src/tests/contracts/abi_v2/{GiverWallet.abi.json => GiverV2.abi.json} (96%) create mode 100644 ton_client/src/tests/contracts/abi_v2/GiverV2.tvc diff --git a/ton_client/src/net/tests.rs b/ton_client/src/net/tests.rs index 19cf565be..830977dcd 100644 --- a/ton_client/src/net/tests.rs +++ b/ton_client/src/net/tests.rs @@ -183,7 +183,7 @@ async fn wait_for() { let client = TestClient::new(); client - .get_tokens_from_giver_async(&TestClient::giver_address(), None) + .get_tokens_from_giver_async(&client.giver_address().await, None) .await; request.await.unwrap(); @@ -431,7 +431,7 @@ async fn subscribe_for_messages() { .unwrap(); client - .get_tokens_from_giver_async(&TestClient::giver_address(), None) + .get_tokens_from_giver_async(&client.giver_address().await, None) .await; assert_eq!(messages.lock().await.len(), 0); @@ -450,7 +450,7 @@ async fn find_last_shard_block() { .request_async( "net.find_last_shard_block", ParamsOfFindLastShardBlock { - address: TestClient::giver_address(), + address: client.giver_address().await, }, ) .await @@ -489,7 +489,7 @@ async fn test_wait_resume() { let duration = tokio::spawn(async move { client_copy - .fetch_account(&TestClient::giver_address()) + .fetch_account(&client_copy.giver_address().await) .await; start.elapsed().as_millis() diff --git a/ton_client/src/processing/tests.rs b/ton_client/src/processing/tests.rs index f7d23a557..955485db2 100644 --- a/ton_client/src/processing/tests.rs +++ b/ton_client/src/processing/tests.rs @@ -338,7 +338,7 @@ async fn test_error_resolving() { call_set: Some(CallSet { function_name: "sendAllMoney".to_owned(), header: None, - input: Some(json!({ "dest_addr": TestClient::giver_address() })), + input: Some(json!({ "dest_addr": client.giver_address().await })), }), }; diff --git a/ton_client/src/tests/common.rs b/ton_client/src/tests/common.rs index 6af58b12f..9555ffcb7 100644 --- a/ton_client/src/tests/common.rs +++ b/ton_client/src/tests/common.rs @@ -113,7 +113,7 @@ async fn test_clock_sync() { let msg = client .encode_message(ParamsOfEncodeMessage { abi: TestClient::abi(HELLO, None), - address: Some(TestClient::giver_address()), + address: Some(client.giver_address().await), call_set: CallSet::some_with_function("touch"), deploy_set: None, processing_try_index: None, diff --git a/ton_client/src/tests/contracts/abi_v2/GiverWallet.abi.json b/ton_client/src/tests/contracts/abi_v2/GiverV2.abi.json similarity index 96% rename from ton_client/src/tests/contracts/abi_v2/GiverWallet.abi.json rename to ton_client/src/tests/contracts/abi_v2/GiverV2.abi.json index 148b574fb..050bdade2 100644 --- a/ton_client/src/tests/contracts/abi_v2/GiverWallet.abi.json +++ b/ton_client/src/tests/contracts/abi_v2/GiverV2.abi.json @@ -1,40 +1,40 @@ -{"ABI version": 2, - "header": ["time", "expire"], - "functions": [ - { - "name": "upgrade", - "inputs": [ - {"name":"newcode","type":"cell"} - ], - "outputs": [ - ] - }, - { - "name": "sendTransaction", - "inputs": [ - {"name":"dest","type":"address"}, - {"name":"value","type":"uint128"}, - {"name":"bounce","type":"bool"} - ], - "outputs": [ - ] - }, - { - "name": "getMessages", - "inputs": [ - ], - "outputs": [ - {"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"} - ] - }, - { - "name": "constructor", - "inputs": [ - ], - "outputs": [ - ] - } - ], - "events": [ - ] +{"ABI version": 2, + "header": ["time", "expire"], + "functions": [ + { + "name": "upgrade", + "inputs": [ + {"name":"newcode","type":"cell"} + ], + "outputs": [ + ] + }, + { + "name": "sendTransaction", + "inputs": [ + {"name":"dest","type":"address"}, + {"name":"value","type":"uint128"}, + {"name":"bounce","type":"bool"} + ], + "outputs": [ + ] + }, + { + "name": "getMessages", + "inputs": [ + ], + "outputs": [ + {"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"} + ] + }, + { + "name": "constructor", + "inputs": [ + ], + "outputs": [ + ] + } + ], + "events": [ + ] } \ No newline at end of file diff --git a/ton_client/src/tests/contracts/abi_v2/GiverV2.tvc b/ton_client/src/tests/contracts/abi_v2/GiverV2.tvc new file mode 100644 index 0000000000000000000000000000000000000000..e06f35ff23c97d6945af2e00f271815136184d70 GIT binary patch literal 999 zcmaKpZD>DexuqiY)nH}ASx|>$lxiYK6jkQ$0wPMH0Ol}L? zz6_I=5Mhjn5k-ou?JQUvVuuW@vb89ik)qc&j%+%wwg}b_omsfBC(inKJHNPWe3=D6w<61R9@YPX{y(hvWr~bpUYvl8F*x(Z z{PvcRF=V&FaeR=@!8nt&yC^N)`#a5OSaGR*`~|0eV&9#{#(t# z2_E!yOvIC%fwFxq?a%*1b9DAvj)__r#*TJt5kXsVq+6>OuFmpTy8l9Lp$VGyl7{Rg zC5@T`ktQ(EmHGGdIQbC$I9Bn^eaZx~G|ZftSN3n6zzNu8uAE)`1!9}YX!d}-&FfU|aCL7lKK zX1sI3D~hkw9jGjfdaDY9wmJj9^GAm~xMtaL!&YTrHd8%XR#1{79*=wTN81AG**{CQ zHk)g$mw5?g(m^7LaAANnNg%-Do7+NR(xv}5a>cR~lF7)lzoG(NK6h{T0mTG$apy?C z|DTB3ZuZNJ!VEj78(pjNyLPbSh+9Hp0Pb<^Nq^wP?Nj?v<5K-^QuwBCB?_KNR(&~6 zlOGpG-N`{N!hZGh)&%7l^vOwFsoJN5whcW2b(BRuyK5Z|s8gkC=~{WX64_m>=hZcW Wn^Jmf(q|SChq&aY52~fBb58-4+lT)E literal 0 HcmV?d00001 diff --git a/ton_client/src/tests/mod.rs b/ton_client/src/tests/mod.rs index 5f4aea236..200c5ed57 100644 --- a/ton_client/src/tests/mod.rs +++ b/ton_client/src/tests/mod.rs @@ -12,9 +12,7 @@ */ use super::{tc_destroy_string, tc_read_string, tc_request, tc_request_sync}; -use crate::abi::{ - encode_message, Abi, CallSet, ParamsOfEncodeMessage, ResultOfEncodeMessage, Signer, -}; +use crate::abi::{Abi, CallSet, DeploySet, ParamsOfEncodeMessage, ResultOfEncodeMessage, Signer, encode_message}; use crate::boc::{ParamsOfParse, ResultOfParse}; use crate::client::*; use crate::crypto::{ @@ -54,7 +52,6 @@ const LOG_CGF_PATH: &str = "src/tests/log_cfg.yaml"; const GIVER_ADDRESS_VAR: &str = "TON_GIVER_ADDRESS"; const GIVER_SECRET_VAR: &str = "TON_GIVER_SECRET"; -const GIVER_KEYS_FILENAME: &str = "giverKeys.json"; struct SimpleLogger; @@ -76,7 +73,7 @@ pub const SUBSCRIBE: &str = "Subscription"; // pub const PIGGY_BANK: &str = "Piggy"; // pub const WALLET: &str = "LimitWallet"; // pub const SIMPLE_WALLET: &str = "Wallet"; -pub const GIVER_WALLET: &str = "GiverWallet"; +pub const GIVER_V2: &str = "GiverV2"; pub const HELLO: &str = "Hello"; pub const EVENTS: &str = "Events"; pub const TEST_DEBOT: &str = "testDebot"; @@ -244,44 +241,45 @@ impl TestClient { } pub fn giver_abi() -> Abi { - Self::abi(GIVER_WALLET, Some(2)) + Self::abi(GIVER_V2, Some(2)) + } + + async fn calc_giver_address(&self, keys: KeyPair) -> String { + self.encode_message( + ParamsOfEncodeMessage { + abi: Self::giver_abi(), + deploy_set: DeploySet::some_with_tvc(Self::tvc(GIVER_V2, None)), + signer: Signer::Keys { keys }, + ..Default::default() + } + ) + .await + .unwrap() + .address } - pub fn giver_address() -> String { - if Self::node_se() { - "0:b5e9240fc2d2f1ff8cbb1d1dee7fb7cae155e5f6320e585fcc685698994a19a5".to_owned() + pub async fn giver_address(&self) -> String { + if let Ok(address) = std::env::var(GIVER_ADDRESS_VAR) { + address } else { - std::env::var(GIVER_ADDRESS_VAR) - .unwrap_or("0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13".to_owned()) + self.calc_giver_address(Self::giver_keys()).await } } pub fn giver_keys() -> KeyPair { - if Self::node_se() { + if let Ok(secret) = std::env::var(GIVER_SECRET_VAR) { + let secret_key = ed25519_dalek::SecretKey::from_bytes(&hex::decode(&secret).unwrap()).unwrap(); + let public_key = ed25519_dalek::PublicKey::from(&secret_key); KeyPair { - public: "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16".to_owned(), - secret: "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3".to_owned(), + public: hex::encode(public_key.to_bytes()), + secret, } } else { - if let Ok(secret) = std::env::var(GIVER_SECRET_VAR) { - let secret_key = ed25519_dalek::SecretKey::from_bytes(&hex::decode(&secret).unwrap()).unwrap(); - let public_key = ed25519_dalek::PublicKey::from(&secret_key); - KeyPair { - public: hex::encode(public_key.to_bytes()), - secret, - } - } else { - let keys_file = dirs::home_dir() - .expect("Error obtaining user's home dir") - .join(GIVER_KEYS_FILENAME); - let keys = std::fs::read_to_string(&keys_file) - .expect(&format!("Error reading file: {:?}", &keys_file)); - - serde_json::from_str(&keys) - .expect(&format!("Error parsing {:?} as JSON", &keys_file)) - } + KeyPair { + public: "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16".to_owned(), + secret: "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3".to_owned(), } - + } } pub fn network_address() -> String { @@ -601,7 +599,7 @@ impl TestClient { pub(crate) async fn get_tokens_from_giver_async(&self, account: &str, value: Option) { let run_result = self.net_process_function( - Self::giver_address(), + self.giver_address().await, Self::giver_abi(), "sendTransaction", json!({ From b5c370aeb73c0faa60cd90336549415c049d2974 Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 18:37:51 +0300 Subject: [PATCH 03/14] Version 1.11.1 --- api/derive/Cargo.toml | 2 +- api/info/Cargo.toml | 2 +- api/test/Cargo.toml | 2 +- ton_client/Cargo.toml | 2 +- ton_sdk/Cargo.toml | 2 +- toncli/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/derive/Cargo.toml b/api/derive/Cargo.toml index 9f6084645..89d1b741e 100644 --- a/api/derive/Cargo.toml +++ b/api/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "api_derive" -version = "1.11.0" +version = "1.11.1" authors = ["TON DEV SOLUTIONS LTD "] edition = "2018" diff --git a/api/info/Cargo.toml b/api/info/Cargo.toml index e543054b7..ffacc8845 100644 --- a/api/info/Cargo.toml +++ b/api/info/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "api_info" -version = "1.11.0" +version = "1.11.1" authors = ["TON DEV SOLUTIONS LTD "] edition = "2018" diff --git a/api/test/Cargo.toml b/api/test/Cargo.toml index 4aada6f5e..c6f19d657 100644 --- a/api/test/Cargo.toml +++ b/api/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "api_test" -version = "1.11.0" +version = "1.11.1" authors = ["TON DEV SOLUTIONS LTD "] edition = "2018" diff --git a/ton_client/Cargo.toml b/ton_client/Cargo.toml index b533d1f4b..e9e787d17 100644 --- a/ton_client/Cargo.toml +++ b/ton_client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ton_client" -version = "1.11.0" +version = "1.11.1" authors = ["TON DEV SOLUTIONS LTD "] edition = "2018" license = "Apache-2.0" diff --git a/ton_sdk/Cargo.toml b/ton_sdk/Cargo.toml index 273a2ad3e..c9ef429bf 100644 --- a/ton_sdk/Cargo.toml +++ b/ton_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ton_sdk" -version = "1.11.0" +version = "1.11.1" edition = "2018" license = "Apache-2.0" authors = ["TON DEV SOLUTIONS LTD "] diff --git a/toncli/Cargo.toml b/toncli/Cargo.toml index cb5712cc6..0cfc69267 100644 --- a/toncli/Cargo.toml +++ b/toncli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "toncli" -version = "1.11.0" +version = "1.11.1" description = "TON CLient Command Line Tool" authors = ["TON DEV SOLUTIONS LTD "] repository = "https://github.com/tonlabs/TON-SDK" From 050c7767537ccef9b5c7daa240d1c3148f3e100a Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 18:40:03 +0300 Subject: [PATCH 04/14] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 518de8a2a..ef547d8a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [1.11.1] – 2021-03-15 + +### New +- Giver address in tests is calculated from secret key. Default values are provided for Node SE giver + ## [1.11.0] – 2021-03-05 ### New From 262f5612723ac6ae678952bcb9b86217d30dae42 Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 18:55:43 +0300 Subject: [PATCH 05/14] DEFAULT_USE_NODE_SE constant --- ton_client/src/tests/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ton_client/src/tests/mod.rs b/ton_client/src/tests/mod.rs index 200c5ed57..ce4e04681 100644 --- a/ton_client/src/tests/mod.rs +++ b/ton_client/src/tests/mod.rs @@ -43,6 +43,7 @@ use tokio::sync::{ mod common; +const DEFAULT_USE_NODE_SE: &str = "true"; const DEFAULT_NETWORK_ADDRESS: &str = "http://localhost"; //const DEFAULT_NETWORK_ADDRESS: &str = "cinet.tonlabs.io"; //const DEFAULT_NETWORK_ADDRESS: &str = "net.ton.dev"; @@ -287,7 +288,7 @@ impl TestClient { } pub fn node_se() -> bool { - std::env::var("USE_NODE_SE").unwrap_or("true".to_owned()) == "true".to_owned() + std::env::var("USE_NODE_SE").unwrap_or(DEFAULT_USE_NODE_SE.to_owned()) == "true".to_owned() } pub fn abi_version() -> u8 { From e7f733db91167a404d35b60ae24d86f850323470 Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Mon, 15 Mar 2021 19:47:34 +0300 Subject: [PATCH 06/14] Tests readme --- README.md | 15 +++++++++++++++ ton_client/src/tests/mod.rs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 030a7491e..182bc6987 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,21 @@ tsc node index binding -l ts -o ../../ton-client-js/packages/core/src ``` +# Run tests +To run test suite use standard Rust test command +``` +cargo test +``` +SDK tests need Dapp server endpoint to run. TONOS SE is used by default with address `http://localhost`. +If you have TONOS SE running at another endpoint or you need to run tests on real TON network use following +environment variables to override default parameters +``` +USE_SE: true/false - flag defining is Dapp server endpoint TONOS SE or real network +TON_NETWORK_ADDRESS - Dapp server endpoint +TON_GIVER_SECRET - Giver secret key. If not defined, default TONOS SE giver keys are used +TON_GIVER_ADDRESS - Address of the giver to use for prepaying accounts before deploying test contracts. If not defined, the address is calculated using `GiverV2.tvc` and configured public key +``` + # Download precompiled binaries Instead of building library yourself, you can download the __latest__ precompiled binaries from diff --git a/ton_client/src/tests/mod.rs b/ton_client/src/tests/mod.rs index ce4e04681..7d4d52c59 100644 --- a/ton_client/src/tests/mod.rs +++ b/ton_client/src/tests/mod.rs @@ -43,7 +43,7 @@ use tokio::sync::{ mod common; -const DEFAULT_USE_NODE_SE: &str = "true"; +const DEFAULT_USE_SE: &str = "true"; const DEFAULT_NETWORK_ADDRESS: &str = "http://localhost"; //const DEFAULT_NETWORK_ADDRESS: &str = "cinet.tonlabs.io"; //const DEFAULT_NETWORK_ADDRESS: &str = "net.ton.dev"; @@ -288,7 +288,7 @@ impl TestClient { } pub fn node_se() -> bool { - std::env::var("USE_NODE_SE").unwrap_or(DEFAULT_USE_NODE_SE.to_owned()) == "true".to_owned() + std::env::var("USE_SE").unwrap_or(DEFAULT_USE_SE.to_owned()) == "true".to_owned() } pub fn abi_version() -> u8 { From a83dbaecac66c94133be4755dc66002fd2be9d5f Mon Sep 17 00:00:00 2001 From: elasticLove1 Date: Mon, 15 Mar 2021 22:29:58 +0300 Subject: [PATCH 07/14] Update README.md --- README.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 182bc6987..97fc70318 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,18 @@ [Example Hello World](https://github.com/tonlabs/sdk-samples/tree/master/v1/node-js/core-api/hello) +- [Documentation](#documentation) +- [What is Core Free TON Client Library](#what-is-core-free-ton-client-library) +- [SDKs in other languages (bindings over TON-SDK)](#sdks-in-other-languages-bindings-over-ton-sdk) + - [Official Javascript(Typescript) SDK](#official-javascripttypescript-sdk) + - [Community bindings](#community-bindings) +- [How to use library](#how-to-use-library) +- [How to avoid Soft Breaking Problems](#how-to-avoid-soft-breaking-problems) +- [Build client library](#build-client-library) +- [Build artifacts](#build-artifacts) +- [Run tests](#run-tests) +- [Download precompiled binaries](#download-precompiled-binaries) + # What is Core Free TON Client Library Core Client Library is written in Rust that can be dynamically linked. It provides all @@ -186,13 +198,16 @@ To run test suite use standard Rust test command ``` cargo test ``` -SDK tests need Dapp server endpoint to run. TONOS SE is used by default with address `http://localhost`. -If you have TONOS SE running at another endpoint or you need to run tests on real TON network use following -environment variables to override default parameters +SDK tests need [TON OS API](https://docs.ton.dev/86757ecb2/p/793337-ton-os-api) endpoint to run on. +Such an API is exposed by a [DApp Server](https://github.com/tonlabs/TON-OS-DApp-Server) which runs in real networks and by local blockchain [TON OS SE](https://github.com/tonlabs/tonos-se). + +TON OS SE is used by default with address `http://localhost` and port 80. If you launch it on another port you need to specify it explicitly like this: `http://localhost:port`. +If you have TON OS SE running on another address or you need to run tests on a real TON network use the following +environment variables to override the default parameters ``` -USE_SE: true/false - flag defining is Dapp server endpoint TONOS SE or real network -TON_NETWORK_ADDRESS - Dapp server endpoint -TON_GIVER_SECRET - Giver secret key. If not defined, default TONOS SE giver keys are used +USE_SE: true/false - flag defining if tests run against TON OS SE or a real network (DApp Server) +TON_NETWORK_ADDRESS - Dapp server or TON OS SE address +TON_GIVER_SECRET - Giver secret key. If not defined, default TON OS SE giver keys are used TON_GIVER_ADDRESS - Address of the giver to use for prepaying accounts before deploying test contracts. If not defined, the address is calculated using `GiverV2.tvc` and configured public key ``` From 833792dab9c48f8a35829050efcbbc61566d88c8 Mon Sep 17 00:00:00 2001 From: elasticLove1 Date: Mon, 15 Mar 2021 22:33:55 +0300 Subject: [PATCH 08/14] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 97fc70318..e345194a9 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,9 @@ [![Channel on Telegram](https://img.shields.io/badge/chat-on%20telegram-9cf.svg)](https://t.me/ton_sdk) -# Documentation -[Full API/SDK documentation](https://docs.ton.dev/86757ecb2/p/39fc5e-products) - -[Javascript SDK](https://github.com/tonlabs/ton-client-js) - -[Example Hello World](https://github.com/tonlabs/sdk-samples/tree/master/v1/node-js/core-api/hello) - -- [Documentation](#documentation) +# Content Table +- [Content Table](#content-table) +- [Useful links](#useful-links) - [What is Core Free TON Client Library](#what-is-core-free-ton-client-library) - [SDKs in other languages (bindings over TON-SDK)](#sdks-in-other-languages-bindings-over-ton-sdk) - [Official Javascript(Typescript) SDK](#official-javascripttypescript-sdk) @@ -26,6 +21,11 @@ - [Build artifacts](#build-artifacts) - [Run tests](#run-tests) - [Download precompiled binaries](#download-precompiled-binaries) + +# Useful links + +[Quick Start](https://docs.ton.dev/86757ecb2/p/33b76d-quick-start) +[Full API/SDK documentation](https://docs.ton.dev/86757ecb2/p/39fc5e-products) # What is Core Free TON Client Library From 42d47afbe464fb76a7bfdf8fcefef107630345cb Mon Sep 17 00:00:00 2001 From: Ekaterina Pantaz <52739957+elasticLove1@users.noreply.github.com> Date: Mon, 15 Mar 2021 22:35:45 +0300 Subject: [PATCH 09/14] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e345194a9..9a048df33 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ # Useful links [Quick Start](https://docs.ton.dev/86757ecb2/p/33b76d-quick-start) + [Full API/SDK documentation](https://docs.ton.dev/86757ecb2/p/39fc5e-products) # What is Core Free TON Client Library From 0e4c6e020f374385236ba9f70ba22e0b353e20ec Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Tue, 16 Mar 2021 08:49:28 +0300 Subject: [PATCH 10/14] TON_USE_SE instead of USE_SE --- README.md | 2 +- ton_client/src/tests/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9a048df33..3e76ba170 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ TON OS SE is used by default with address `http://localhost` and port 80. If you If you have TON OS SE running on another address or you need to run tests on a real TON network use the following environment variables to override the default parameters ``` -USE_SE: true/false - flag defining if tests run against TON OS SE or a real network (DApp Server) +TON_USE_SE: true/false - flag defining if tests run against TON OS SE or a real network (DApp Server) TON_NETWORK_ADDRESS - Dapp server or TON OS SE address TON_GIVER_SECRET - Giver secret key. If not defined, default TON OS SE giver keys are used TON_GIVER_ADDRESS - Address of the giver to use for prepaying accounts before deploying test contracts. If not defined, the address is calculated using `GiverV2.tvc` and configured public key diff --git a/ton_client/src/tests/mod.rs b/ton_client/src/tests/mod.rs index 7d4d52c59..8c699829e 100644 --- a/ton_client/src/tests/mod.rs +++ b/ton_client/src/tests/mod.rs @@ -43,7 +43,7 @@ use tokio::sync::{ mod common; -const DEFAULT_USE_SE: &str = "true"; +const DEFAULT_TON_USE_SE: &str = "true"; const DEFAULT_NETWORK_ADDRESS: &str = "http://localhost"; //const DEFAULT_NETWORK_ADDRESS: &str = "cinet.tonlabs.io"; //const DEFAULT_NETWORK_ADDRESS: &str = "net.ton.dev"; @@ -288,7 +288,7 @@ impl TestClient { } pub fn node_se() -> bool { - std::env::var("USE_SE").unwrap_or(DEFAULT_USE_SE.to_owned()) == "true".to_owned() + std::env::var("TON_USE_SE").unwrap_or(DEFAULT_TON_USE_SE.to_owned()) == "true".to_owned() } pub fn abi_version() -> u8 { From 2d7a85b20dc4b4d0ac55c352c284c284c76e8431 Mon Sep 17 00:00:00 2001 From: Sergei Voronezhskii Date: Tue, 16 Mar 2021 17:49:33 +0300 Subject: [PATCH 11/14] Update api.json --- tools/api.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/api.json b/tools/api.json index ced95989a..172d431b8 100644 --- a/tools/api.json +++ b/tools/api.json @@ -1,5 +1,5 @@ { - "version": "1.11.0", + "version": "1.11.1", "modules": [ { "name": "client", From 96738b05d7ba7d4aabf44043309951154077598b Mon Sep 17 00:00:00 2001 From: Alexey Vavilin Date: Tue, 16 Mar 2021 19:02:55 +0300 Subject: [PATCH 12/14] Skip test_debot_sdk_get_accounts_by_hash --- ton_client/src/debot/tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ton_client/src/debot/tests.rs b/ton_client/src/debot/tests.rs index 696977792..0538f2414 100644 --- a/ton_client/src/debot/tests.rs +++ b/ton_client/src/debot/tests.rs @@ -1109,6 +1109,8 @@ async fn test_debot_invoke_msgs() { ).await; } +// TODO: make test runnable not only once +#[ignore] #[tokio::test(core_threads = 2)] async fn test_debot_sdk_get_accounts_by_hash() { let client = std::sync::Arc::new(TestClient::new()); From f908c5fd335718f8ddaa555c4b6432060889e8d8 Mon Sep 17 00:00:00 2001 From: Ekaterina Pantaz <52739957+elasticLove1@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:22:00 +0300 Subject: [PATCH 13/14] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef547d8a9..5354bae2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ## [1.11.1] – 2021-03-15 ### New -- Giver address in tests is calculated from secret key. Default values are provided for Node SE giver +- Giver address in tests is calculated from secret key. Default values are provided for TON OS SE giver ## [1.11.0] – 2021-03-05 From b47d1f4611eea279c482f3858db5cd60f25fe73b Mon Sep 17 00:00:00 2001 From: elasticLove1 Date: Tue, 16 Mar 2021 22:23:26 +0300 Subject: [PATCH 14/14] change node se to ton os se --- ton_client/src/processing/blocks_walking.rs | 6 +++--- ton_client/src/processing/tests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ton_client/src/processing/blocks_walking.rs b/ton_client/src/processing/blocks_walking.rs index 9514b5510..54d6659e4 100644 --- a/ton_client/src/processing/blocks_walking.rs +++ b/ton_client/src/processing/blocks_walking.rs @@ -71,7 +71,7 @@ pub async fn find_last_shard_block( // if account is from other chains, then starting point is last account's shard block // To obtain it we take masterchain block to get shards configuration and select matching shard if blocks[0].is_null() { - // Node SE case - no masterchain, no sharding. Check that only one shard + // TON OS SE case - no masterchain, no sharding. Check that only one shard let blocks = client .query_collection(ParamsOfQueryCollection { collection: BLOCKS_TABLE_NAME.to_string(), @@ -93,7 +93,7 @@ pub async fn find_last_shard_block( workchain ))); } - // if workchain is sharded, then it is not Node SE and masterchain blocks missing is error + // if workchain is sharded, then it is not TON OS SE and masterchain blocks missing is error if blocks[0]["after_merge"] == true || blocks[0]["shard"] != "8000000000000000" { return Err(Error::block_not_found( "No masterchain block found".to_owned(), @@ -120,7 +120,7 @@ pub async fn find_last_shard_block( .as_str() .map(|val| val.to_owned().into()) .ok_or(Error::block_not_found( - "No starting Node SE block found".to_owned(), + "No starting TON OS SE block found".to_owned(), )) } else { let shards = diff --git a/ton_client/src/processing/tests.rs b/ton_client/src/processing/tests.rs index 955485db2..94c513975 100644 --- a/ton_client/src/processing/tests.rs +++ b/ton_client/src/processing/tests.rs @@ -292,7 +292,7 @@ async fn test_process_message() { #[tokio::test(core_threads = 2)] async fn test_error_resolving() { - // skip on Node SE since it behaves different to real node + // skip on TON OS SE since it behaves different to real node if TestClient::node_se() { return; }