Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
poplexity committed Jan 17, 2024
1 parent 5b49911 commit 729161c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 7 additions & 2 deletions crates/antelope/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ impl Display for HTTPMethod {

// TODO: Make this return an APIResponse with status code, timing, etc..
pub trait Provider: Debug + Default + Sync + Send {
fn post(&self, path: String, body: Option<String>) -> impl std::future::Future<Output = Result<String, String>> + Send;
fn get(&self, path: String) -> impl std::future::Future<Output = Result<String, String>> + Send;
fn post(
&self,
path: String,
body: Option<String>,
) -> impl std::future::Future<Output = Result<String, String>> + Send;
fn get(&self, path: String)
-> impl std::future::Future<Output = Result<String, String>> + Send;
}

#[derive(Debug, Default, Clone)]
Expand Down
8 changes: 6 additions & 2 deletions crates/antelope/src/api/default_provider.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::client::Provider;
use std::fmt::{Debug, Formatter};
use reqwest::Client;
use std::fmt::{Debug, Formatter};

#[derive(Default, Clone)]
pub struct DefaultProvider {
Expand Down Expand Up @@ -37,7 +37,11 @@ impl Debug for DefaultProvider {

impl Provider for DefaultProvider {
async fn get(&self, path: String) -> Result<String, String> {
let res = self.client.get(self.base_url.to_string() + &path).send().await;
let res = self
.client
.get(self.base_url.to_string() + &path)
.send()
.await;
if res.is_err() {
return Err(res.err().unwrap().to_string());
}
Expand Down
8 changes: 6 additions & 2 deletions crates/antelope/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ async fn chain_send_transaction() {
mock_provider::make_mock_transaction(&info, Asset::from_string("0.0420 NUNYA"));
let signed_invalid_transaction =
mock_provider::sign_mock_transaction(&invalid_transaction, &info);
let failed_result = client.v1_chain.send_transaction(signed_invalid_transaction).await;
let failed_result = client
.v1_chain
.send_transaction(signed_invalid_transaction)
.await;
assert!(
failed_result.is_err(),
"Failed transaction result should be err"
Expand Down Expand Up @@ -108,7 +111,8 @@ pub async fn chain_get_table_rows() {
reverse: None,
index_position: None,
show_payer: None,
}).await
})
.await
.unwrap();

assert_eq!(res1.rows.len(), 1, "Should get 1 row back");
Expand Down

0 comments on commit 729161c

Please sign in to comment.