-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Description --- Adds smoke test to check if provider works and can perform: 1. create account 2. get free coins 3. fetch balances Motivation and Context --- Test are needed to quick check basic app functionality. How Has This Been Tested? --- What process can a PR reviewer use to test or verify this change? --- <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
use tokio::time::{ self, Duration }; | ||
|
||
use crate::rpc::{ balances, free_coins, permission_token }; | ||
|
||
#[tokio::test] | ||
async fn get_account_balance() { | ||
let timeout_duration = Duration::from_secs(30); | ||
let (permission_token, _auth_token) = permission_token().await.unwrap(); | ||
let account_name = "default".to_string(); | ||
let get_tokens_result = time::timeout( | ||
timeout_duration, | ||
free_coins(Some(account_name.clone()), permission_token.clone()) | ||
).await; | ||
|
||
match get_tokens_result { | ||
Ok(Ok(value)) => { | ||
let resp = value.as_str().unwrap_or("").to_string(); | ||
assert_eq!(resp, "default"); | ||
} | ||
Ok(Err(e)) => panic!("Function returned an error: {}", e), | ||
Err(_) => panic!("Function 'free_coins' timed out!"), | ||
} | ||
|
||
let get_balance_result = time::timeout(timeout_duration, balances(Some(account_name), permission_token)).await; | ||
|
||
match get_balance_result { | ||
Ok(Ok(res)) => { | ||
let address = res.address.is_component(); | ||
assert_eq!(address, true); | ||
} | ||
Ok(Err(e)) => panic!("Function returned an error: {}", e), | ||
Err(_) => panic!("Function 'balances' timed out!"), | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
mod account_test; |