-
Notifications
You must be signed in to change notification settings - Fork 11
feat(interact): implement simple interact #17
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
base: main
Are you sure you want to change the base?
Changes from all commits
07f66bf
59b3a91
9c25622
aa3fd23
55346bc
fa4e428
fab612f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,3 +69,5 @@ jobs: | |
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: test | ||
| args: TEST_CONFIG=test_config_example.json | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| { | ||
| "full_node_url": "https://example.com", | ||
| "network_id": "testnet", | ||
| "test_node_url": "https://rpc.testnet.near.org", | ||
| "account_public": "example.testnet.public", | ||
| "account_private": "example.testnet.private", | ||
| "wasm_binary_path": "example/path" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| use reqwest::Client; | ||
| use serde::{Deserialize, Serialize}; | ||
| use serde_json::{json, Value}; | ||
| use tokio::time::{sleep, Duration}; | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct Config { | ||
| full_node_url: String, | ||
| network_id: String, | ||
| test_node_url: String, | ||
| account_public: String, | ||
| account_private: String, | ||
| wasm_binary_path: String, | ||
|
|
@@ -23,28 +27,94 @@ impl Config { | |
| } | ||
|
|
||
| #[tokio::test] | ||
| #[ignore] | ||
| async fn check_connection() { | ||
| let _config = Config::read_from_env(); | ||
| let config = Config::read_from_env(); | ||
| // check whether the full node is responding by a simple request | ||
| unimplemented!(); | ||
| let client = Client::new(); | ||
| let payload = json!({ | ||
| "jsonrpc": "2.0", | ||
| "id": "dontcare", | ||
| "method": "status", | ||
| "params": [] | ||
| }); | ||
|
|
||
| let res = client | ||
| .post(&config.test_node_url) | ||
| .json(&payload) | ||
| .send() | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let json = res.json::<Value>().await.unwrap(); | ||
| assert_eq!(json["result"]["chain_id"], config.network_id); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| #[ignore] | ||
| async fn check_block_number() { | ||
| let _config = Config::read_from_env(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. |
||
| // check the latest block number recognized by the full node **twice** with some delay, | ||
| // so that we can assure that the full node is properly updating its blocks | ||
| unimplemented!(); | ||
| let client = Client::new(); | ||
| let payload = json!({ | ||
| "jsonrpc": "2.0", | ||
| "id": "dontcare", | ||
| "method": "block", | ||
| "params": { | ||
| "finality": "final" | ||
| } | ||
| }); | ||
|
|
||
| let first_res = client | ||
| .post(&_config.test_node_url) | ||
| .json(&payload) | ||
| .send() | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let first_json = first_res.json::<Value>().await.unwrap(); | ||
|
|
||
| sleep(Duration::from_secs(2)).await; | ||
|
|
||
| let second_res = client | ||
| .post(&_config.test_node_url) | ||
| .json(&payload) | ||
| .send() | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let second_json = second_res.json::<Value>().await.unwrap(); | ||
|
|
||
| assert!( | ||
| second_json["result"]["header"]["height"].as_u64() | ||
| > first_json["result"]["header"]["height"].as_u64() | ||
| ); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| #[ignore] | ||
| async fn check_account() { | ||
| let _config = Config::read_from_env(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. |
||
| // by requesting the full node, check whether the account given by the config has enough native token to pay gas fee | ||
| unimplemented!(); | ||
| let client = Client::new(); | ||
| let payload = json!({ | ||
| "jsonrpc": "2.0", | ||
| "id": "dontcare", | ||
| "method": "query", | ||
| "params": { | ||
| "request_type": "view_account", | ||
| "finality": "final", | ||
| "account_id": "nearkat.testnet" | ||
| } | ||
| }); | ||
|
|
||
| let res = client | ||
| .post(&_config.test_node_url) | ||
| .json(&payload) | ||
| .send() | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let json = res.json::<Value>().await.unwrap(); | ||
| assert_eq!(json["error"], Value::Null); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| #[tokio::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.
무관한 커밋에 들어있습니다.
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.
fixed in 3497363